43562023-03-26 19:46:14KevinLeghosszabb nyaralás (75 pont)cpp17Wrong answer 55/7527ms4720 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, p;
	cin >> n;
	cin >> p;
	vector<int> a(n);
	for (int i=0; i<n ;i++)
		cin >> a[i];
	
	int elso=-1;
	int utolso=-1;
	int osszeg=0;
	int megoldas=0;
	while (utolso < n){
		while (a[utolso+1]>p){
			utolso++;
			elso=utolso;
		}
		utolso++;
		osszeg=osszeg+a[utolso];
		while (osszeg>p){
			osszeg=osszeg-a[elso];
			elso++;
		}
		if (utolso-elso+1>megoldas)
			megoldas=utolso-elso+1;
	}
	cout << megoldas;
}
SubtaskSumTestVerdictTimeMemory
base55/75
1Accepted0/03ms1812 KiB
2Accepted0/027ms2764 KiB
3Wrong answer0/32ms2120 KiB
4Wrong answer0/32ms2312 KiB
5Accepted3/32ms2532 KiB
6Accepted3/33ms2736 KiB
7Wrong answer0/33ms2848 KiB
8Wrong answer0/42ms2932 KiB
9Accepted4/43ms3072 KiB
10Accepted5/53ms3168 KiB
11Accepted5/54ms3316 KiB
12Accepted5/54ms3316 KiB
13Wrong answer0/719ms4256 KiB
14Accepted7/723ms4332 KiB
15Accepted7/727ms4444 KiB
16Accepted8/826ms4532 KiB
17Accepted8/827ms4720 KiB