93772024-02-21 10:50:04Vkrisztian01Leggyorsabb pénzkeresés (50)cpp17Accepted 50/5032ms4304 KiB
#include <iostream>
#include<algorithm>

using namespace std;

int ki=1e9;

int main()
{
    int n,p,osszeg=0,i=0,j=0;
    cin>>n>>p;
    int nums[n];
    for(int i=0;i<n;i++) cin>>nums[i];
    while(i!=n)
    {
        while(j<n && osszeg<p)
        {
            osszeg+=nums[j];
            ++j;
        }
        if(j==n && osszeg<p) break;
        while(osszeg>=p)
        {
            //cout<<i<<" "<<j-1<<endl;
            ki=min(j-i,ki);
            osszeg-=nums[i];
            ++i;
        }
    }
    cout<<ki;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/032ms3052 KiB
3Accepted2/23ms2240 KiB
4Accepted2/23ms2272 KiB
5Accepted2/22ms2272 KiB
6Accepted2/26ms2436 KiB
7Accepted2/24ms2524 KiB
8Accepted2/24ms2588 KiB
9Accepted2/24ms2588 KiB
10Accepted2/24ms2584 KiB
11Accepted2/232ms3452 KiB
12Accepted2/232ms3664 KiB
13Accepted2/232ms3876 KiB
14Accepted2/232ms3956 KiB
15Accepted2/232ms3960 KiB
16Accepted2/232ms3960 KiB
17Accepted2/232ms4088 KiB
18Accepted2/232ms4084 KiB
19Accepted2/232ms3960 KiB
20Accepted2/232ms4084 KiB
21Accepted2/232ms4088 KiB
22Accepted2/232ms3964 KiB
23Accepted2/232ms3960 KiB
24Accepted2/232ms4084 KiB
25Accepted2/232ms4168 KiB
26Accepted2/232ms4304 KiB
27Accepted2/232ms4168 KiB