27142023-01-19 11:12:20bzsofiaLádapakolás raktárban (50)cpp11Elfogadva 50/5050ms11128 KiB
// lada.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <map>

using namespace std;

long long db, i, n, hight, sum;
map <long long, long long> st;

int main()
{
    cin >> n >> hight;
    vector <long long> x(n + 1);

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

    i = 1;
    while (i <= n)
    {
        st.clear();
        sum = x[i];
        st[x[i]] = 1;
        ++i;
        while (i<=n && x[i-1] < x[i] && sum+x[i]<=hight)
        {
            sum += x[i];
            st[x[i]] = 1;
            ++i;
            ++db;
        }
        while (i<=n && x[i-1] > x[i] && sum + x[i] <= hight && st[x[i]]!=1)
        {
            sum += x[i];
            ++i;
            ++db;
        }
    }

    cout << db;
    return 0;
}
/*
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ÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1680 KiB
2Elfogadva0/04ms2196 KiB
3Elfogadva2/22ms2176 KiB
4Elfogadva2/22ms2252 KiB
5Elfogadva2/22ms2376 KiB
6Elfogadva2/22ms2508 KiB
7Elfogadva2/22ms2588 KiB
8Elfogadva2/22ms2780 KiB
9Elfogadva3/32ms2984 KiB
10Elfogadva2/22ms2984 KiB
11Elfogadva2/22ms3116 KiB
12Elfogadva2/23ms3296 KiB
13Elfogadva3/34ms3648 KiB
14Elfogadva3/34ms3876 KiB
15Elfogadva3/36ms3644 KiB
16Elfogadva2/232ms5088 KiB
17Elfogadva3/341ms5120 KiB
18Elfogadva3/350ms5124 KiB
19Elfogadva3/335ms5380 KiB
20Elfogadva3/348ms9740 KiB
21Elfogadva3/343ms9948 KiB
22Elfogadva3/346ms11128 KiB