41412023-03-15 13:59:12gittyLeggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5032ms3716 KiB
#include <iostream>
#include <queue>
#include <fstream>
using namespace std;

int main()
{
    //ifstream cin("in.txt");
    queue <int> pieces;
    int n, p;
    cin>>n>>p;
    int x;
    int s=0;
    int minl=100000;
    for(int i = 1; i<=n; i++)
    {
        cin>>x;
        s+=x;
        pieces.push(x);
        if(s>=p)
        {
            while(s-pieces.front() > p && !pieces.empty())
            {
                s-=pieces.front();
                pieces.pop();
            }
            if(pieces.size() < minl)
            {
                //cout<<pieces.size()<<"\n";
                minl = pieces.size();
            }
        }
    }
    cout<<minl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Wrong answer0/03ms1816 KiB
2Accepted0/030ms2012 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2452 KiB
5Accepted2/23ms2532 KiB
6Accepted2/24ms2452 KiB
7Accepted2/24ms2576 KiB
8Accepted2/24ms2668 KiB
9Accepted2/24ms2660 KiB
10Accepted2/26ms2796 KiB
11Accepted2/230ms2992 KiB
12Accepted2/230ms3128 KiB
13Accepted2/230ms3084 KiB
14Accepted2/230ms3080 KiB
15Accepted2/232ms3088 KiB
16Accepted2/230ms3224 KiB
17Accepted2/230ms3404 KiB
18Accepted2/232ms3256 KiB
19Accepted2/230ms3268 KiB
20Accepted2/230ms3492 KiB
21Accepted2/230ms3568 KiB
22Accepted2/232ms3584 KiB
23Accepted2/230ms3716 KiB
24Wrong answer0/232ms3672 KiB
25Wrong answer0/230ms3672 KiB
26Accepted2/230ms3676 KiB
27Accepted2/232ms3672 KiB