53852023-04-30 09:53:35Laci3000Leghosszabb nyaralás (75 pont)cpp17Wrong answer 58/7512ms6716 KiB
// nt sipalya.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <vector>
#include <iostream>

using namespace std;


int main()
{
	cin.sync_with_stdio(false);
	cin.tie(nullptr);
	int days, money;
	
	cin >> days >> money;
	vector<int> listS(days);
	for (size_t i = 0; i < days; i++)
	{
		cin >> listS[i];
	}
	int l = 0, r = 0;
	int max_hossz = 0, aktual, penz = listS[0];

	while (l < days - max_hossz) {
		while (penz + listS[r + 1] <= money) {
			r++;
			penz += listS[r];
		}
		aktual = r - l + 1;
		if (max_hossz < aktual) {
			max_hossz = aktual;
		}
		
		penz -= listS[l];
		l++;
	}
	cout << max_hossz << '\n';
}

SubtaskSumTestVerdictTimeMemory
base58/75
1Accepted0/03ms1824 KiB
2Accepted0/012ms3228 KiB
3Accepted3/33ms2492 KiB
4Wrong answer0/33ms2712 KiB
5Accepted3/33ms2932 KiB
6Accepted3/33ms3064 KiB
7Wrong answer0/33ms3280 KiB
8Wrong answer0/43ms3356 KiB
9Accepted4/43ms3492 KiB
10Accepted5/53ms3476 KiB
11Accepted5/53ms3520 KiB
12Accepted5/54ms3804 KiB
13Runtime error0/79ms5028 KiB
14Accepted7/710ms5124 KiB
15Accepted7/712ms5716 KiB
16Accepted8/812ms6120 KiB
17Accepted8/812ms6716 KiB