8632022-01-21 12:13:30zsebiLeggyorsabb pénzkeresés (50)cpp11Time limit exceeded 16/50298ms2012 KiB
#include <iostream>
#include <vector>
#include <climits>


#define ll long long

using namespace std;
ll i,p,n,j,db,s,mini;
vector <ll> x;
int main()
{
    cin.sync();
    cin>>n>>p;
    x.resize(n+1);
    for(i=1;i<=n;++i)
    {
        cin>>x[i];
    }

    mini=INT_MAX;
    i=1;
    while(i<=n)
    {

        s=x[i];
        if(s>=p)
        {
            mini=1;
            break;
        }
        else
        for(j=i+1;j<=n;++j)
        {
            s+=x[j];

            if(s>=p && j-i+1<mini)
            {
               mini=j-i+1;
               break;
            }
        }
        ++i;
    }
    cout<<mini;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/50
1Accepted0/02ms1804 KiB
2Time limit exceeded0/0284ms1796 KiB
3Accepted2/21ms1916 KiB
4Accepted2/21ms1824 KiB
5Accepted2/21ms1824 KiB
6Accepted2/264ms2008 KiB
7Accepted2/264ms2008 KiB
8Accepted2/261ms2004 KiB
9Accepted2/267ms2012 KiB
10Accepted2/263ms2008 KiB
11Time limit exceeded0/2296ms1716 KiB
12Time limit exceeded0/2291ms1772 KiB
13Time limit exceeded0/2275ms1780 KiB
14Time limit exceeded0/2287ms1780 KiB
15Time limit exceeded0/2298ms1720 KiB
16Time limit exceeded0/2298ms1848 KiB
17Time limit exceeded0/2296ms1844 KiB
18Time limit exceeded0/2298ms1784 KiB
19Time limit exceeded0/2284ms1784 KiB
20Time limit exceeded0/2284ms1780 KiB
21Time limit exceeded0/2291ms1716 KiB
22Time limit exceeded0/2298ms1716 KiB
23Time limit exceeded0/2246ms1784 KiB
24Time limit exceeded0/2298ms1788 KiB
25Time limit exceeded0/2298ms1716 KiB
26Time limit exceeded0/2296ms1716 KiB
27Time limit exceeded0/2298ms1716 KiB