8067 2024. 01. 12 11:50:38 gkata Ládapakolás raktárban (50) cpp17 Elfogadva 50/50 57ms 10816 KiB
// ladapakolas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <map>
#define ll long long

using namespace std;

map<ll, ll>st;

ll db, i, n, m, s;

int main()
{
    cin >> n >> m;

    vector<ll>x(n + 1);

    for (i = 1; i <= n; ++i) cin >> x[i];

    i = 1;
    while (i <= n)
    {
        st.clear();
        s = x[i];
        st[x[i]] = 1;
        ++i;

        while (i <= n && x[i - 1] < x[i] && s + x[i] <= m)
        {
            s += x[i];
            st[x[i]] = 1;
            ++i;
            ++db;
        }
        while (i <= n && x[i - 1] > x[i] && s + x[i] <= m && st[x[i]] != 1)
        {
            s += x[i];
            ++i;
            ++db;
        }
    }

    cout << db;
}

/*
12 16
1 3 5 4 2 6 8 7 6 5 3 4
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Részfeladat Összpont Teszt Verdikt Idő Memória
base 50/50
1 Elfogadva 0/0 3ms 1684 KiB
2 Elfogadva 0/0 6ms 2048 KiB
3 Elfogadva 2/2 3ms 2060 KiB
4 Elfogadva 2/2 3ms 2304 KiB
5 Elfogadva 2/2 3ms 2512 KiB
6 Elfogadva 2/2 3ms 2764 KiB
7 Elfogadva 2/2 3ms 2944 KiB
8 Elfogadva 2/2 3ms 3160 KiB
9 Elfogadva 3/3 3ms 3396 KiB
10 Elfogadva 2/2 3ms 3516 KiB
11 Elfogadva 2/2 3ms 3760 KiB
12 Elfogadva 2/2 4ms 3884 KiB
13 Elfogadva 3/3 4ms 4116 KiB
14 Elfogadva 3/3 4ms 4096 KiB
15 Elfogadva 3/3 7ms 4364 KiB
16 Elfogadva 2/2 35ms 5596 KiB
17 Elfogadva 3/3 46ms 5680 KiB
18 Elfogadva 3/3 57ms 5768 KiB
19 Elfogadva 3/3 39ms 5696 KiB
20 Elfogadva 3/3 52ms 10008 KiB
21 Elfogadva 3/3 46ms 9776 KiB
22 Elfogadva 3/3 50ms 10816 KiB