90172024-02-12 10:49:42IgnácLeghosszabb nyaralás (75 pont)cpp17Runtime error 0/753ms4920 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/03ms1908 KiB
2Runtime error0/03ms3004 KiB
3Runtime error0/33ms2336 KiB
4Runtime error0/33ms2556 KiB
5Runtime error0/33ms2692 KiB
6Runtime error0/33ms3120 KiB
7Runtime error0/33ms2984 KiB
8Runtime error0/43ms3044 KiB
9Runtime error0/43ms3124 KiB
10Runtime error0/53ms3340 KiB
11Runtime error0/53ms3468 KiB
12Runtime error0/53ms3744 KiB
13Runtime error0/73ms4596 KiB
14Runtime error0/73ms4696 KiB
15Runtime error0/73ms4724 KiB
16Runtime error0/83ms4888 KiB
17Runtime error0/83ms4920 KiB