9912022-02-19 18:26:29JMMirkoLeghosszabb nyaralás (75 pont)cpp14Wrong answer 61/7524ms4652 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,p,a;
    bool b;
    cin >> n >> p;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    int ossz=0,m=0;
    ossz=v[0];
    int j=1;
    for(int i=0;i<n-m;i++){
        b=false;
        while(!b){
            if(ossz<=p){
                ossz+=v[j];
                j++;
            }else{
                if(j-i-1>m){
                    m=j-i-1;

                }
                ossz=ossz-v[i];
                b=true;
            }
        }

    }
    cout << m;
    return 0;
}

/*

15

20 20 30 40

*/
SubtaskSumTestVerdictTimeMemory
base61/75
1Accepted0/02ms1740 KiB
2Accepted0/021ms2896 KiB
3Accepted3/31ms2240 KiB
4Wrong answer0/31ms2236 KiB
5Accepted3/32ms2240 KiB
6Accepted3/31ms2244 KiB
7Accepted3/31ms2244 KiB
8Wrong answer0/41ms2248 KiB
9Accepted4/41ms2260 KiB
10Accepted5/51ms2260 KiB
11Accepted5/53ms2304 KiB
12Accepted5/54ms2336 KiB
13Runtime error0/716ms3316 KiB
14Accepted7/720ms3524 KiB
15Accepted7/723ms3928 KiB
16Accepted8/823ms4176 KiB
17Accepted8/824ms4652 KiB