1622021-02-03 20:29:14Halasz EszterLeggyorsabb pénzkeresés (50)cpp11Time limit exceeded 46/50238ms2832 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;
            }
            if(veg-kezd+1>mini) break;
        }
    }

    cout<<mini;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/02ms1800 KiB
2Time limit exceeded0/0234ms2820 KiB
3Accepted2/21ms2080 KiB
4Accepted2/21ms2076 KiB
5Accepted2/21ms2076 KiB
6Accepted2/26ms2120 KiB
7Accepted2/220ms2116 KiB
8Accepted2/230ms2112 KiB
9Accepted2/26ms2120 KiB
10Accepted2/218ms2112 KiB
11Accepted2/226ms2804 KiB
12Time limit exceeded0/2238ms2828 KiB
13Accepted2/2165ms2820 KiB
14Accepted2/263ms2812 KiB
15Accepted2/2160ms2832 KiB
16Accepted2/257ms2812 KiB
17Accepted2/254ms2820 KiB
18Accepted2/287ms2828 KiB
19Accepted2/2197ms2828 KiB
20Accepted2/2135ms2820 KiB
21Accepted2/285ms2808 KiB
22Accepted2/2116ms2820 KiB
23Time limit exceeded0/2229ms2832 KiB
24Accepted2/2128ms2828 KiB
25Accepted2/2136ms2832 KiB
26Accepted2/281ms2832 KiB
27Accepted2/279ms2820 KiB