222662026-01-14 19:01:26szabelrLádapakolás raktárban (50)cpp17Wrong answer 32/5014ms552 KiB
// Ládapakolás raktárban.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    long long m;
    cin >> n >> m;
    int stacks = 0;          
    long long current_sum = 0; 
    int last_height = 0;     
    bool descending = false; 

    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        bool uj = false;

        if (stacks == 0) {
            uj = true;
        }
        else if (current_sum + x > m) {
            uj = true;
        }
        else if (x == last_height) {
            uj = true;
        }
        else if (descending && x > last_height) {
            uj = true;
        }

        if (uj) {
            stacks++;          
            current_sum = x;    
            last_height = x;
            descending = false; 
        }
        else {
            current_sum += x;
            if (x < last_height) {
                descending = true; 
            }
            last_height = x;
        }
    }
    cout << n - stacks << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/02ms500 KiB
2Wrong answer0/03ms316 KiB
3Accepted2/21ms508 KiB
4Wrong answer0/22ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms552 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Accepted2/21ms332 KiB
11Accepted2/21ms316 KiB
12Wrong answer0/21ms420 KiB
13Accepted3/32ms316 KiB
14Wrong answer0/32ms316 KiB
15Accepted3/33ms316 KiB
16Wrong answer0/210ms508 KiB
17Accepted3/313ms420 KiB
18Accepted3/314ms424 KiB
19Accepted3/38ms316 KiB
20Wrong answer0/39ms424 KiB
21Wrong answer0/38ms316 KiB
22Wrong answer0/310ms424 KiB