39112023-03-03 22:45:13BttrngLeghosszabb nyaralás (75 pont)cpp17Time limit exceeded 35/75300ms5416 KiB
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int main(){
    int n, p;
    cin>>n>>p;
    vector<int>ar(n+1);
    v.resize(n+1);
    for(int i=1; i<=n; i++){
        cin>>ar[i];
        v[i]=v[i-1]+ar[i];
    }
    int maxi=0;
    for(int i=n; i>=1; i--){
        int k=v[i]-p;
        int j=1;
        while(v[j]<k) j++;
        j=i-j;
        maxi=max(j, maxi);
    }
    cout<<maxi;


}
SubtaskSumTestVerdictTimeMemory
base35/75
1Accepted0/03ms1808 KiB
2Time limit exceeded0/0300ms2048 KiB
3Accepted3/33ms2232 KiB
4Wrong answer0/33ms2448 KiB
5Accepted3/33ms2656 KiB
6Accepted3/33ms2864 KiB
7Accepted3/33ms3220 KiB
8Accepted4/43ms3300 KiB
9Accepted4/43ms3312 KiB
10Accepted5/53ms3472 KiB
11Accepted5/517ms3716 KiB
12Accepted5/535ms3816 KiB
13Wrong answer0/720ms5416 KiB
14Time limit exceeded0/7300ms4020 KiB
15Time limit exceeded0/7280ms4140 KiB
16Time limit exceeded0/8270ms4020 KiB
17Time limit exceeded0/8263ms4188 KiB