222572026-01-14 18:54:02szabelrLádapakolás raktárban (50)cpp17Wrong answer 0/5014ms544 KiB
// Ládapakolás raktárban.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    long long saved = 0;
    long long curheight = 0;
    int statusv = 0;
    //1 csokken 2no
    int elozo = -1;
    bool kezde = true;
    int a = 0;
    for (int i = 1; i <= n; i++)
    {
        int x; cin >> x;
        if (!kezde)
        {
            if (elozo != x)
            {
                if (statusv == 0)
                {
                    if (elozo < x)
                        statusv = 2;
                    else
                        statusv = 1;
                }
                else if(statusv==1 and elozo<x)
                {
                    statusv = 4;
                }
                else if (statusv == 2 and elozo > x)
                {
                    statusv = 3;
                }
                else if (statusv == 4 and elozo > x)
                {
                    statusv = 5;
                }
                else if (statusv == 3 and elozo < x)
                {
                    statusv = 5;
                }
            }
        }
        else if(x <= m)
            kezde = false;
        if (!kezde and curheight + x <= m and statusv<5)
        {
            curheight += x;
            elozo = x;
            saved++;
        }
        else
        {
            curheight = x;
            kezde = true;
            elozo = x;
            statusv = 0;
            a++;
        }
            
    }
    cout << saved-a+1 << endl;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/02ms316 KiB
2Wrong answer0/02ms316 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms508 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms324 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/31ms512 KiB
14Wrong answer0/32ms500 KiB
15Wrong answer0/32ms316 KiB
16Wrong answer0/210ms316 KiB
17Wrong answer0/313ms544 KiB
18Wrong answer0/314ms424 KiB
19Wrong answer0/38ms316 KiB
20Wrong answer0/39ms428 KiB
21Wrong answer0/38ms316 KiB
22Wrong answer0/310ms428 KiB