1332021-01-21 20:52:37kidesoLeghosszabb nyaralás (75 pont)cpp11Accepted 75/7525ms2832 KiB
#include <iostream>
#include <vector>

using namespace std;

int N, F, a, b, maxi, sum;

int main()
{
	cin >> N >> F;
	vector <int> x(N + 1, 0);

	for (int i = 1; i <= N; ++i)
		cin >> x[i];

	a = 1;
	sum = x[1];
	maxi = 0;

	for (b = 2; b <= N; ++b)
	{
		sum += x[b];
		while (sum > F)
		{
			sum -= x[a];
			++a;
		}

		if (b - a + 1 > maxi) maxi = b - a + 1;
	}

	cout << maxi << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/02ms1768 KiB
2Accepted0/024ms2832 KiB
3Accepted3/31ms1980 KiB
4Accepted3/31ms2088 KiB
5Accepted3/31ms2084 KiB
6Accepted3/31ms2084 KiB
7Accepted3/31ms1976 KiB
8Accepted4/41ms1976 KiB
9Accepted4/41ms1976 KiB
10Accepted5/51ms2088 KiB
11Accepted5/53ms2120 KiB
12Accepted5/54ms2124 KiB
13Accepted7/717ms2828 KiB
14Accepted7/719ms2824 KiB
15Accepted7/723ms2832 KiB
16Accepted8/825ms2832 KiB
17Accepted8/825ms2828 KiB