9992022-02-20 16:04:33Kevinke12Leggyorsabb pénzkeresés (50)cpp14Accepted 50/5043ms12912 KiB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll N, P, be1;
vector<ll> t;

int main()
{
    cin >> N >> P;
    for(int i = 0; i < N; i++)
    {
        cin >> be1;
        t.push_back(be1);
    }

    int v=0; //[i,v[
    ll aktO=0;
    int ans = N;

    for(int i = 0; i < N;i++)
    {
        while((v<N) && (aktO<P))
        {
            aktO+=t[v];
            v++;
        }
        //cout << i << "-" << v  << "=" << aktO<< "\n";
        if(aktO>=P)
            ans = min(ans, v-i);
        aktO-=t[i];

    }
    cout << ans << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1872 KiB
2Accepted0/029ms4348 KiB
3Accepted2/21ms2404 KiB
4Accepted2/21ms2404 KiB
5Accepted2/21ms2408 KiB
6Accepted2/24ms2856 KiB
7Accepted2/24ms2896 KiB
8Accepted2/24ms2940 KiB
9Accepted2/24ms2988 KiB
10Accepted2/24ms3036 KiB
11Accepted2/229ms5072 KiB
12Accepted2/228ms5556 KiB
13Accepted2/228ms6164 KiB
14Accepted2/229ms6524 KiB
15Accepted2/232ms7000 KiB
16Accepted2/228ms7592 KiB
17Accepted2/228ms7968 KiB
18Accepted2/229ms8436 KiB
19Accepted2/228ms8928 KiB
20Accepted2/243ms9488 KiB
21Accepted2/229ms9896 KiB
22Accepted2/229ms10500 KiB
23Accepted2/228ms10856 KiB
24Accepted2/228ms11340 KiB
25Accepted2/228ms11820 KiB
26Accepted2/229ms12332 KiB
27Accepted2/229ms12912 KiB