27122023-01-19 10:54:30bzsofiaLádapakolás raktárban (50)cpp11Hibás válasz 32/5046ms5356 KiB
// lada.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

long long db, i, n, hight, sum;

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)
    {
        sum = x[i];
        ++i;
        ++db;
        while (i<=n && x[i-1] < x[i] && sum+x[i]<=hight)
        {
            sum += x[i];
            ++i;
        }
        while (i<=n && x[i-1] > x[i] && sum + x[i] <= hight)
        {
            sum += x[i];
            ++i;
        }
    }

    cout << n-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
base32/50
1Elfogadva0/03ms1812 KiB
2Hibás válasz0/04ms2260 KiB
3Elfogadva2/22ms2260 KiB
4Hibás válasz0/22ms2408 KiB
5Elfogadva2/22ms2616 KiB
6Elfogadva2/22ms2688 KiB
7Elfogadva2/22ms2812 KiB
8Elfogadva2/22ms3056 KiB
9Elfogadva3/32ms3264 KiB
10Elfogadva2/22ms3220 KiB
11Elfogadva2/22ms3216 KiB
12Hibás válasz0/23ms3480 KiB
13Elfogadva3/33ms3348 KiB
14Hibás válasz0/34ms3368 KiB
15Elfogadva3/34ms3428 KiB
16Hibás válasz0/228ms4824 KiB
17Elfogadva3/337ms5140 KiB
18Elfogadva3/346ms5356 KiB
19Elfogadva3/328ms5020 KiB
20Hibás válasz0/330ms5068 KiB
21Hibás válasz0/328ms4956 KiB
22Hibás válasz0/332ms5212 KiB