85992024-01-23 06:59:33BenedekMartonLeggyorsabb pénzkeresés (50)cpp17Accepted 50/5032ms4420 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    long long p, osz=0;
    cin >> n >> p;
    int f[n];
    for(int i=0; i<n; i++)
    {
        cin >> f[i];
    }
    int e=0, v=-1, minap=100000000;
    while(v<n-1)
    {
        v++;
        osz=osz+f[v];
        if(osz>=p)
        {
            minap=min(minap, v-e+1);

            while(osz>=p and v>e)
            {
                osz=osz-f[e];
                e++;
                if(osz>=p)
                {
                    minap=min(minap, v-e+1);
                }
            }
        }
    //cout << e << " " << v << " " << osz << endl;
    }
    if(osz>=p)
    {
        minap=min(minap, v-e+1);
    }
    cout << minap;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/032ms2888 KiB
3Accepted2/23ms2212 KiB
4Accepted2/23ms2412 KiB
5Accepted2/23ms2496 KiB
6Accepted2/24ms2532 KiB
7Accepted2/24ms2500 KiB
8Accepted2/24ms2756 KiB
9Accepted2/26ms2968 KiB
10Accepted2/24ms2924 KiB
11Accepted2/232ms3660 KiB
12Accepted2/232ms3932 KiB
13Accepted2/232ms3944 KiB
14Accepted2/232ms4020 KiB
15Accepted2/232ms4208 KiB
16Accepted2/232ms4296 KiB
17Accepted2/232ms4296 KiB
18Accepted2/232ms4292 KiB
19Accepted2/232ms4292 KiB
20Accepted2/232ms4292 KiB
21Accepted2/232ms4292 KiB
22Accepted2/232ms4296 KiB
23Accepted2/232ms4316 KiB
24Accepted2/232ms4420 KiB
25Accepted2/232ms4296 KiB
26Accepted2/232ms4292 KiB
27Accepted2/232ms4292 KiB