42872023-03-22 10:51:37gkataLeggyorsabb pénzkeresés (50)cpp17Time limit exceeded 44/50286ms5956 KiB
#include <iostream>
#include <queue>
#define ll long long

using namespace std;

//ifstream cin("penz.in");
//ofstream cout("penz.out");

vector <ll>x;
ll a,h,i,n,p,s,r,v,k;
bool ok=false;

int main()
{
    cin>>n>>p;
    x.resize(n+1);

    for(i=1;i<=n;++i)
    {
        cin>>a;
        s+=a;
        x[i]=s;
    }
    //for(auto &e:x) cout<<e<<" ";

    for(h=1;h<=n;++h)
     {
        for(a=1;a<=n-h+1;++a)
        {
            r=x[a+h-1]-x[a-1];
            if(x[a+h-1]-x[a-1]>=p)
            {
                ok=true;
                k=a;
                v=a+h-1;
                break;
            }
        }
        if(ok) break;
     }

     cout<<h;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1876 KiB
2Time limit exceeded0/0273ms3616 KiB
3Accepted2/23ms2400 KiB
4Accepted2/23ms2400 KiB
5Accepted2/23ms2596 KiB
6Accepted2/28ms2724 KiB
7Accepted2/220ms3040 KiB
8Accepted2/228ms3312 KiB
9Accepted2/28ms3284 KiB
10Accepted2/224ms3332 KiB
11Accepted2/229ms4500 KiB
12Time limit exceeded0/2286ms4520 KiB
13Accepted2/2199ms4888 KiB
14Accepted2/272ms4672 KiB
15Accepted2/2194ms4760 KiB
16Accepted2/271ms4760 KiB
17Accepted2/264ms4972 KiB
18Accepted2/293ms5232 KiB
19Time limit exceeded0/2224ms3520 KiB
20Accepted2/2162ms5136 KiB
21Accepted2/2101ms5100 KiB
22Accepted2/2137ms5092 KiB
23Time limit exceeded0/2241ms3936 KiB
24Accepted2/2134ms5524 KiB
25Accepted2/2171ms5736 KiB
26Accepted2/298ms5956 KiB
27Accepted2/297ms5956 KiB