59572023-10-06 13:55:44mmatedLeghosszabb nyaralás (75 pont)cpp17Wrong answer 68/7514ms8484 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,m;
    cin>>n>>m;
    int p[n+1];
    p[0]=0;
    int x;
    cin>>x;
    p[1]=x;
    f(i,2,n+1)
    {
        cin>>x;
        p[i]=p[i-1]+x;
    }
    if(p[n]<=m)
    {
        cout<<n;
        return;
    }
    vector<int> a;
    int kezd=0, veg=1;

    while(kezd<=veg && veg<n)
    {
        if(p[veg]-p[kezd]<=m)
        {
            a.push_back(veg-kezd);
            veg++;
        }
        else
        {
            kezd++;
        }
    }
    int maxi=0;
    for(auto q: a) if(maxi<q)   maxi=q;
    cout<<maxi;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base68/75
1Accepted0/03ms2104 KiB
2Accepted0/013ms4488 KiB
3Accepted3/33ms2952 KiB
4Accepted3/33ms3108 KiB
5Accepted3/32ms3116 KiB
6Wrong answer0/32ms3332 KiB
7Accepted3/33ms3540 KiB
8Wrong answer0/43ms3756 KiB
9Accepted4/43ms4120 KiB
10Accepted5/53ms4224 KiB
11Accepted5/54ms4564 KiB
12Accepted5/54ms4612 KiB
13Accepted7/79ms5320 KiB
14Accepted7/712ms7056 KiB
15Accepted7/714ms7788 KiB
16Accepted8/814ms8160 KiB
17Accepted8/814ms8484 KiB