43032023-03-22 19:16:11gkataLeggyorsabb pénzkeresés (50)cpp17Time limit exceeded 44/50261ms5988 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()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    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/03ms1888 KiB
2Time limit exceeded0/0254ms3588 KiB
3Accepted2/23ms2444 KiB
4Accepted2/23ms2652 KiB
5Accepted2/23ms2760 KiB
6Accepted2/27ms2888 KiB
7Accepted2/218ms3016 KiB
8Accepted2/226ms3280 KiB
9Accepted2/26ms3236 KiB
10Accepted2/221ms3496 KiB
11Accepted2/212ms4920 KiB
12Time limit exceeded0/2261ms3760 KiB
13Accepted2/2180ms5456 KiB
14Accepted2/254ms5412 KiB
15Accepted2/2175ms5364 KiB
16Accepted2/252ms5300 KiB
17Accepted2/245ms5452 KiB
18Accepted2/275ms5644 KiB
19Time limit exceeded0/2224ms5772 KiB
20Accepted2/2143ms5840 KiB
21Accepted2/282ms5800 KiB
22Accepted2/2119ms5868 KiB
23Time limit exceeded0/2257ms5732 KiB
24Accepted2/2115ms5732 KiB
25Accepted2/2152ms5988 KiB
26Accepted2/279ms5936 KiB
27Accepted2/279ms5940 KiB