44242023-03-27 19:06:16KevinLeghosszabb nyaralás (75 pont)cpp17Wrong answer 58/7527ms4408 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=0;
	int utolso=-1;
	int osszeg=0;
	int megoldas=0;
	while (utolso < n){
		while (a[utolso+1]>p){
			utolso++;
			elso=utolso+1;
		}
		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
base58/75
1Accepted0/03ms1808 KiB
2Accepted0/027ms2764 KiB
3Accepted3/33ms2268 KiB
4Wrong answer0/33ms2664 KiB
5Accepted3/33ms2704 KiB
6Accepted3/33ms2864 KiB
7Wrong answer0/32ms2788 KiB
8Wrong answer0/42ms2852 KiB
9Accepted4/43ms2996 KiB
10Accepted5/53ms2932 KiB
11Accepted5/54ms3196 KiB
12Accepted5/54ms3236 KiB
13Wrong answer0/719ms4120 KiB
14Accepted7/723ms4260 KiB
15Accepted7/726ms4236 KiB
16Accepted8/826ms4288 KiB
17Accepted8/826ms4408 KiB