238852026-01-31 14:23:27mihalykocsisLeghosszabb nyaralás (75 pont)cpp17Accepted 75/7525ms800 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    int money; cin >> money;
    vector<int> days(n);
    for (int i = 0; i < n; i++) {
        cin >> days[i];
    }

    int maxLength = 0;
    int sum = 0;
    int left = 0;

    for (int right = 0; right < n; right++) {
        sum += days[right];
        while (sum > money) {
            sum -= days[left];
            left++;
        }
        maxLength = max(maxLength, right - left + 1);
    }

    cout << maxLength << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms500 KiB
2Accepted0/025ms564 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms376 KiB
9Accepted4/41ms316 KiB
10Accepted5/51ms316 KiB
11Accepted5/53ms508 KiB
12Accepted5/53ms316 KiB
13Accepted7/717ms796 KiB
14Accepted7/720ms800 KiB
15Accepted7/725ms796 KiB
16Accepted8/824ms796 KiB
17Accepted8/825ms800 KiB