146622025-01-25 22:33:3042thebestestLeghosszabb nyaralás (75 pont)cpp17Accepted 75/7525ms936 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, K, mosszeg = 0, maxh = 0, m, start = 0; cin >> N >> K;
    vector<int> napok;
    for (int j = 0; j < N; j++) {
        cin >> m;
        napok.push_back(m);
    }
    for (int i = 0; i < N; i++) {
        mosszeg+=napok[i];
        while(mosszeg>K) {
            mosszeg -= napok[start];
            start++;
        }
        maxh = max(maxh, i-start+1);
    }
    cout << maxh << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms316 KiB
2Accepted0/025ms936 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms508 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted5/51ms316 KiB
11Accepted5/53ms316 KiB
12Accepted5/54ms508 KiB
13Accepted7/718ms932 KiB
14Accepted7/721ms928 KiB
15Accepted7/725ms832 KiB
16Accepted8/824ms936 KiB
17Accepted8/825ms900 KiB