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

#include <bits/stdc++.h>
#include <iostream>
#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/03ms3112 KiB
3Runtime error0/33ms2388 KiB
4Runtime error0/33ms2508 KiB
5Runtime error0/33ms2788 KiB
6Runtime error0/33ms3012 KiB
7Runtime error0/33ms3188 KiB
8Runtime error0/43ms3360 KiB
9Runtime error0/43ms3500 KiB
10Runtime error0/53ms3712 KiB
11Runtime error0/53ms4024 KiB
12Runtime error0/53ms3972 KiB
13Runtime error0/73ms4520 KiB
14Runtime error0/73ms4520 KiB
15Runtime error0/73ms4520 KiB
16Runtime error0/83ms4520 KiB
17Runtime error0/83ms4648 KiB