14282022-09-11 11:38:04HorakZsofiLeghosszabb nyaralás (75 pont)cpp11Accepted 75/7527ms4676 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, k;
	cin>>n>>k;
	int ossz=0;;
	vector<int>napok(n+1);
	napok[0]=0;
	for(int i=1; i<n+1; i++){
		int a;
		cin>>a;
		ossz+=a;
		napok[i]=ossz;
	}
	int j=0;
	int maxinap=0;
	for(int i=1; i<n+1; i++){
		while(j<=n && napok[j]-napok[i-1]<=k){
			if(j-i+1>maxinap){
				maxinap=j-i+1;
			}
			j++;
		}
	}
	cout<<maxinap;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1684 KiB
2Accepted0/027ms2556 KiB
3Accepted3/32ms2048 KiB
4Accepted3/32ms2256 KiB
5Accepted3/32ms2324 KiB
6Accepted3/32ms2464 KiB
7Accepted3/32ms2696 KiB
8Accepted4/42ms2948 KiB
9Accepted4/42ms2980 KiB
10Accepted5/52ms3060 KiB
11Accepted5/54ms3100 KiB
12Accepted5/54ms3312 KiB
13Accepted7/719ms4332 KiB
14Accepted7/723ms4396 KiB
15Accepted7/726ms4524 KiB
16Accepted8/825ms4628 KiB
17Accepted8/826ms4676 KiB