41422023-03-15 14:00:23gittyLeggyorsabb pénzkeresés (50)cpp17Wrong answer 46/5032ms4388 KiB
#include <iostream>
#include <queue>
#include <fstream>
using namespace std;

int main()
{
    //ifstream cin("in.txt");
    queue <long long int> pieces;
    long long int n, p;
    cin>>n>>p;
    long long int x;
    long long int s=0;
    long long 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/032ms2064 KiB
3Accepted2/23ms2136 KiB
4Accepted2/23ms2264 KiB
5Accepted2/22ms2344 KiB
6Accepted2/24ms2308 KiB
7Accepted2/24ms2316 KiB
8Accepted2/26ms2456 KiB
9Accepted2/24ms2536 KiB
10Accepted2/24ms2664 KiB
11Accepted2/232ms2756 KiB
12Accepted2/232ms2864 KiB
13Accepted2/232ms2872 KiB
14Accepted2/232ms2948 KiB
15Accepted2/232ms2980 KiB
16Accepted2/232ms3180 KiB
17Accepted2/232ms3408 KiB
18Accepted2/232ms3620 KiB
19Accepted2/232ms3716 KiB
20Accepted2/232ms3840 KiB
21Accepted2/232ms3920 KiB
22Accepted2/232ms4024 KiB
23Accepted2/232ms4148 KiB
24Wrong answer0/232ms4132 KiB
25Wrong answer0/232ms4256 KiB
26Accepted2/232ms4304 KiB
27Accepted2/232ms4388 KiB