9902022-02-19 18:17:24JMMirkoLeghosszabb nyaralás (75 pont)cpp14Wrong answer 39/7537ms4652 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]+v[1];
    int j=2;
    for(int i=1;i<n-m;i++){
        b=false;
        while(!b){
            if(ossz<p){
                ossz+=v[j];
                j++;
            }else{
                if(j-i+1>m){
                    m=j-i;

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

    }
    cout << m;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base39/75
1Accepted0/02ms1768 KiB
2Wrong answer0/023ms2980 KiB
3Accepted3/31ms2232 KiB
4Wrong answer0/31ms2236 KiB
5Wrong answer0/31ms2244 KiB
6Accepted3/31ms2240 KiB
7Wrong answer0/31ms2248 KiB
8Accepted4/41ms2248 KiB
9Accepted4/41ms2260 KiB
10Wrong answer0/51ms2260 KiB
11Accepted5/53ms2304 KiB
12Accepted5/53ms2328 KiB
13Runtime error0/717ms3308 KiB
14Wrong answer0/718ms3524 KiB
15Accepted7/720ms3928 KiB
16Wrong answer0/823ms4180 KiB
17Accepted8/837ms4652 KiB