85872024-01-22 14:54:40Balki22Leggyorsabb pénzkeresés (50)cpp17Accepted 50/5032ms13100 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, p;
	cin >> n >> p;
	vector<int> pref(n+1, 0);
	for (int i = 0; i < n; i++) {
		int m; cin >> m;
		pref[i+1] = pref[i] + m;
	}
	int minnapok = n;
	int l = 0;
	int r = 1;
	while (r < n + 2) {
		if (pref[r] - pref[l] >= p) {
			minnapok = min(minnapok, r-l);
			l++;
		}
		else r++;
	}
	cout << minnapok;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/032ms3232 KiB
3Accepted2/23ms2604 KiB
4Accepted2/23ms2808 KiB
5Accepted2/23ms3024 KiB
6Accepted2/26ms3552 KiB
7Accepted2/24ms3784 KiB
8Accepted2/24ms3760 KiB
9Accepted2/26ms4104 KiB
10Accepted2/24ms4092 KiB
11Accepted2/232ms5336 KiB
12Accepted2/232ms5800 KiB
13Accepted2/232ms6172 KiB
14Accepted2/232ms6648 KiB
15Accepted2/232ms7352 KiB
16Accepted2/232ms7800 KiB
17Accepted2/232ms8284 KiB
18Accepted2/232ms8760 KiB
19Accepted2/232ms9368 KiB
20Accepted2/232ms9888 KiB
21Accepted2/232ms10328 KiB
22Accepted2/232ms10820 KiB
23Accepted2/232ms11184 KiB
24Accepted2/232ms11656 KiB
25Accepted2/232ms12140 KiB
26Accepted2/232ms12744 KiB
27Accepted2/232ms13100 KiB