239022026-01-31 15:51:59PKBLeghosszabb nyaralás (75 pont)cpp17Accepted 75/7526ms1080 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
    long long hossz = 0;
    long long leghosszabb = 0;
	long long N;
    cin >> N;
    long long penz;
    cin >> penz;
    long long i = 0; long long j = 0;
    long long mostani = 0;
    vector<long long>szamok(N);
    for(long long h = 0; h < N; h++){
        cin >> szamok[h];
    }
    while (i < N) {
        mostani+= szamok[i];
        i++;
            
            
        while (mostani > penz) { 
            mostani-= szamok[j];
            j++;
            
        }

        leghosszabb = max(leghosszabb, i-j);
        
    }
    cout << leghosszabb;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms316 KiB
2Accepted0/025ms1076 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted5/51ms316 KiB
11Accepted5/53ms316 KiB
12Accepted5/54ms316 KiB
13Accepted7/718ms1076 KiB
14Accepted7/721ms1076 KiB
15Accepted7/725ms1076 KiB
16Accepted8/824ms1080 KiB
17Accepted8/826ms1076 KiB