16122022-11-29 10:28:32kicsiboglarLeggyorsabb pénzkeresés (50)cpp11Accepted 50/50158ms5768 KiB
#include <iostream>
#include <vector>
#define ll long long 

using namespace std;

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

ll n,m,i,j,a,b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin>>n>>m;
    vector <ll> x(n+1,0);
    for (i=1;i<=n;++i)
    {
        cin>>a;
        if (a>=m)
        {
            cout<<'1';
            return 0;
        }
        x[i]=x[i-1]+a;
    }

    if (x[n]<m) 
    {
        cout<<"0";
        return 0;
    }
    for (b=2;b<=n;++b)
    {
        for (i=1;i<=(n-b+1);++i)
        {
            if (x[i+b-1]-x[i-1]>=m)
            {
                cout<<b;
                return 0;
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/0150ms3484 KiB
3Accepted2/22ms2352 KiB
4Accepted2/22ms2452 KiB
5Accepted2/22ms2660 KiB
6Accepted2/24ms3044 KiB
7Accepted2/212ms3244 KiB
8Accepted2/216ms3468 KiB
9Accepted2/24ms3416 KiB
10Accepted2/214ms3600 KiB
11Accepted2/212ms4960 KiB
12Accepted2/2158ms5100 KiB
13Accepted2/2108ms5104 KiB
14Accepted2/235ms5308 KiB
15Accepted2/2105ms5312 KiB
16Accepted2/235ms5376 KiB
17Accepted2/230ms5372 KiB
18Accepted2/248ms5380 KiB
19Accepted2/2133ms5504 KiB
20Accepted2/286ms5504 KiB
21Accepted2/252ms5504 KiB
22Accepted2/272ms5508 KiB
23Accepted2/2152ms5568 KiB
24Accepted2/271ms5760 KiB
25Accepted2/290ms5708 KiB
26Accepted2/250ms5704 KiB
27Accepted2/250ms5768 KiB