16112022-11-29 10:27:22kicsiboglarLeggyorsabb pénzkeresés (50)cpp11Time limit exceeded 44/50282ms6124 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;
    }

    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
base44/50
1Accepted0/03ms1828 KiB
2Time limit exceeded0/0268ms3484 KiB
3Accepted2/22ms2244 KiB
4Accepted2/22ms2468 KiB
5Accepted2/22ms2808 KiB
6Accepted2/26ms2836 KiB
7Accepted2/219ms3104 KiB
8Accepted2/227ms3304 KiB
9Accepted2/26ms3512 KiB
10Accepted2/223ms3584 KiB
11Accepted2/210ms4780 KiB
12Time limit exceeded0/2282ms4908 KiB
13Accepted2/2190ms4968 KiB
14Accepted2/257ms5248 KiB
15Accepted2/2186ms5368 KiB
16Accepted2/254ms5332 KiB
17Accepted2/246ms5312 KiB
18Accepted2/279ms5504 KiB
19Time limit exceeded0/2237ms5708 KiB
20Accepted2/2150ms5788 KiB
21Accepted2/287ms6104 KiB
22Accepted2/2126ms6056 KiB
23Time limit exceeded0/2256ms4736 KiB
24Accepted2/2122ms6056 KiB
25Accepted2/2160ms6124 KiB
26Accepted2/283ms6088 KiB
27Accepted2/282ms6020 KiB