90182024-02-12 10:54:06IgnácLeghosszabb nyaralás (75 pont)cpp17Runtime error 0/753ms5372 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include <vector>
using namespace std;

int main() {
	int n, p;
	cin >> n >> p;
	int j = 0, maxi = 0;
	long long sum;
	vector<int> b(n);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		b[i] = a;
		sum += a;
		while (sum > p) {
			sum -= b[j];
			j++;
		}

		if (i - j + 1 > maxi) maxi = i - j + 1;
	}

	cout << maxi;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/03ms1912 KiB
2Runtime error0/03ms3236 KiB
3Runtime error0/33ms2524 KiB
4Runtime error0/33ms2368 KiB
5Runtime error0/33ms2452 KiB
6Runtime error0/33ms2556 KiB
7Runtime error0/33ms2988 KiB
8Runtime error0/43ms2820 KiB
9Runtime error0/43ms2988 KiB
10Runtime error0/53ms3256 KiB
11Runtime error0/53ms3428 KiB
12Runtime error0/53ms3636 KiB
13Runtime error0/73ms4588 KiB
14Runtime error0/73ms4840 KiB
15Runtime error0/73ms4896 KiB
16Runtime error0/83ms5108 KiB
17Runtime error0/83ms5372 KiB