41392023-03-15 13:41:46gittyLeggyorsabb pénzkeresés (50)cpp17Wrong answer 2/5032ms4864 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;
    //f>>n>>p;
    int x;
    int s=0;
    int minl=100000;
    //cout<<n<<" "<<p;
    for(int i =1; i<=n; i++)
    {
        //f>>x;
        cin>>x;
        if(s+x < p)
        {
            s+=x;
            pieces.push(x);
        }
        else
        {
            while(s-pieces.back() > p)
            {
                s-=pieces.back();
                pieces.pop();
            }
            if(pieces.size() < minl)
            {
                //cout<<pieces.size()<<" ";
                minl = pieces.size();
            }
        }
    }
    cout<<minl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/03ms1812 KiB
2Wrong answer0/030ms2056 KiB
3Wrong answer0/23ms2272 KiB
4Wrong answer0/23ms2480 KiB
5Wrong answer0/23ms2568 KiB
6Wrong answer0/24ms2692 KiB
7Wrong answer0/24ms2728 KiB
8Wrong answer0/24ms2732 KiB
9Wrong answer0/24ms2848 KiB
10Wrong answer0/24ms3068 KiB
11Accepted2/230ms3144 KiB
12Wrong answer0/230ms3300 KiB
13Wrong answer0/230ms3404 KiB
14Wrong answer0/230ms3608 KiB
15Wrong answer0/230ms3700 KiB
16Wrong answer0/230ms3692 KiB
17Wrong answer0/230ms3684 KiB
18Wrong answer0/230ms4080 KiB
19Wrong answer0/230ms4000 KiB
20Wrong answer0/230ms4144 KiB
21Wrong answer0/230ms4248 KiB
22Wrong answer0/232ms4384 KiB
23Wrong answer0/230ms4476 KiB
24Wrong answer0/230ms4580 KiB
25Wrong answer0/230ms4660 KiB
26Wrong answer0/230ms4740 KiB
27Wrong answer0/230ms4864 KiB