87852024-01-30 06:57:01BenedekMartonLádapakolás raktárban (50)cpp17Wrong answer 30/5048ms4708 KiB
#include <iostream>
#include <algorithm>

using namespace std;



int main()
{
    int n, m, x, y;
    cin >> n >> m;
    int szk=0, osz=0;
    int moe=0, moir=0;
    cin >> y;
    osz=y;
    for(int i=0; i<n-1; i++)
    {
        cin >> x;
        //cout << x << " " << y << " " << moir << endl;
        if(y<x)
        {
            if(moir==-1)
            {
                moe++;
            }
            moir=1;
            //cout << "haho" << moir << endl;
        }
        else if(y>x)
        {
            if(moir==1)
            {
                moe++;
            }
            moir=-1;
        }

        if(osz+x<=m and moe<2 and !(moir==1 and moe==1))
        {
            //cout << x;
            osz=osz+x;
        }
        else
        {
            moe=0;
            szk++;
            moir=0;
            osz=x;
            //cout << "v";
        }
        y=x;
        //cout << y << " " << moir << " " << moe << " " << osz <<  " " << szk << endl;

    }
    if(osz>0)
    {
        szk++;
    }

    //cout << endl;
    cout << n-szk;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/50
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2120 KiB
3Accepted2/23ms2612 KiB
4Wrong answer0/23ms2684 KiB
5Accepted2/23ms2916 KiB
6Accepted2/23ms2968 KiB
7Accepted2/23ms3208 KiB
8Accepted2/23ms3392 KiB
9Accepted3/33ms3632 KiB
10Accepted2/23ms3744 KiB
11Wrong answer0/23ms3956 KiB
12Wrong answer0/23ms4092 KiB
13Accepted3/34ms4304 KiB
14Wrong answer0/34ms4332 KiB
15Accepted3/36ms4332 KiB
16Wrong answer0/228ms4580 KiB
17Accepted3/337ms4704 KiB
18Accepted3/348ms4560 KiB
19Accepted3/329ms4560 KiB
20Wrong answer0/332ms4708 KiB
21Wrong answer0/329ms4584 KiB
22Wrong answer0/334ms4476 KiB