87842024-01-30 06:43:01BenedekMartonLádapakolás raktárban (50)cpp17Wrong answer 8/5048ms7676 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 i!=n-2)
        {
            //cout << x;
            osz=osz+x;
        }
        else
        {
            moe=0;
            szk++;
            moir=0;
            osz=x;
            //cout << "v";
        }
        y=x;
        //cout << y << " " << moir << " " << moe << " " << osz <<  " " << szk << endl;

    }
    szk++;
    //cout << endl;
    cout << n-szk;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/50
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2248 KiB
3Wrong answer0/23ms2376 KiB
4Accepted2/22ms2460 KiB
5Accepted2/22ms2416 KiB
6Accepted2/23ms2656 KiB
7Accepted2/22ms2636 KiB
8Wrong answer0/22ms2640 KiB
9Wrong answer0/32ms2644 KiB
10Wrong answer0/23ms2772 KiB
11Wrong answer0/23ms3024 KiB
12Wrong answer0/23ms3076 KiB
13Wrong answer0/34ms3348 KiB
14Wrong answer0/34ms3464 KiB
15Wrong answer0/36ms3408 KiB
16Wrong answer0/228ms3868 KiB
17Wrong answer0/339ms4544 KiB
18Wrong answer0/348ms5464 KiB
19Wrong answer0/329ms6156 KiB
20Wrong answer0/330ms6700 KiB
21Wrong answer0/329ms7040 KiB
22Wrong answer0/334ms7676 KiB