1192021-01-16 11:21:05Valaki2Leghosszabb nyaralás (75 pont)cpp14Wrong answer 72/7521ms2580 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for(int& i : v) cin >> i;
    int l = 0;
    int r = 0;
    long long sum = v[0];
    int maxi = 0/*, lans = -1, rans = -1*/;
    while(l < n) {
        /*if(r < n - 1) {
            if(v[r+1] > k) {
                l = r + 2;
                r = r + 2;
                if(r < n) {
                    sum = v[r];
                } else break;
            }
        }*/
        while(r < n - 1 && sum + v[r+1] <= k) {
            ++r;
            sum += v[r];
        }
        //if(r-l+1>maxi){lans=l;rans=r;}
        maxi = max(r - l + 1, maxi);
        ++l;
        sum -= v[l-1];
    }
    //cout << lans+1 << " " << rans+1 << "\n";
    cout << maxi << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/01ms1736 KiB
2Accepted0/021ms2572 KiB
3Accepted3/31ms1828 KiB
4Accepted3/31ms1724 KiB
5Accepted3/31ms1828 KiB
6Accepted3/31ms1828 KiB
7Wrong answer0/31ms1828 KiB
8Accepted4/41ms1724 KiB
9Accepted4/41ms1724 KiB
10Accepted5/51ms1828 KiB
11Accepted5/53ms1864 KiB
12Accepted5/53ms1868 KiB
13Accepted7/716ms2572 KiB
14Accepted7/717ms2576 KiB
15Accepted7/721ms2580 KiB
16Accepted8/820ms2580 KiB
17Accepted8/820ms2572 KiB