1612021-02-03 20:26:11Halasz EszterLeggyorsabb pénzkeresés (50)cpp11Time limit exceeded 16/50296ms10124 KiB
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

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

vector<int>x;

long long n,m,i,j,sum,kezd,mini=999999,veg;

int main()
{
    cin>>n>>m;
    x.resize(n+1);
    for(i=1;i<=n;++i)
        {
            cin>>x[i];
            if(x[i]>=m)
            {
                cout<<1;
                n=0;
                break;
            }
       }

    if(n!=0)
    {
        for(i=1;i<=n;++i)
    {
        sum=0;
        sum+=x[i];
        kezd=i;
        for(j=i+1;j<=n;++j)
        {
            sum+=x[j];
            veg=j;
            if(sum>=m && veg-kezd+1<mini)
            {
                mini=veg-kezd+1;
                break;
            }
        }
    }

    cout<<mini;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/50
1Accepted0/02ms1804 KiB
2Time limit exceeded0/0296ms1696 KiB
3Accepted2/21ms2364 KiB
4Accepted2/21ms2376 KiB
5Accepted2/21ms2376 KiB
6Accepted2/259ms2420 KiB
7Accepted2/254ms2464 KiB
8Accepted2/254ms2516 KiB
9Accepted2/257ms2564 KiB
10Accepted2/252ms2608 KiB
11Time limit exceeded0/2280ms2600 KiB
12Time limit exceeded0/2282ms2952 KiB
13Time limit exceeded0/2296ms3436 KiB
14Time limit exceeded0/2296ms3924 KiB
15Time limit exceeded0/2296ms4400 KiB
16Time limit exceeded0/2294ms4880 KiB
17Time limit exceeded0/2287ms5364 KiB
18Time limit exceeded0/2275ms5780 KiB
19Time limit exceeded0/2296ms6328 KiB
20Time limit exceeded0/2282ms6816 KiB
21Time limit exceeded0/2291ms7292 KiB
22Time limit exceeded0/2280ms7844 KiB
23Time limit exceeded0/2286ms8176 KiB
24Time limit exceeded0/2294ms8756 KiB
25Time limit exceeded0/2296ms9232 KiB
26Time limit exceeded0/2286ms9712 KiB
27Time limit exceeded0/2282ms10124 KiB