40562023-03-11 23:40:48xxxLeghosszabb nyaralás (75 pont)cpp14Accepted 75/7527ms4636 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, p;
    cin >> n >> p;
    int a[n];
    int ossz = 0, ans = 0, ansmax = 0;
    int elozo = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ossz += a[i];
        ans++;
        while (ossz > p) {
            ossz -= a[elozo];
            elozo++;
            ans--;
        }
        ansmax = max(ans, ansmax);
    }

    cout << ansmax << endl;

}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1876 KiB
2Accepted0/027ms2892 KiB
3Accepted3/33ms2328 KiB
4Accepted3/33ms2540 KiB
5Accepted3/33ms2788 KiB
6Accepted3/32ms2876 KiB
7Accepted3/33ms2816 KiB
8Accepted4/42ms2888 KiB
9Accepted4/43ms3128 KiB
10Accepted5/53ms3220 KiB
11Accepted5/54ms3264 KiB
12Accepted5/54ms3388 KiB
13Accepted7/719ms4232 KiB
14Accepted7/723ms4236 KiB
15Accepted7/726ms4476 KiB
16Accepted8/826ms4556 KiB
17Accepted8/826ms4636 KiB