27132023-01-19 11:05:22bzsofiaLádapakolás raktárban (50)cpp11Hibás válasz 32/5046ms5452 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;
        while (i<=n && x[i-1] < x[i] && sum+x[i]<=hight)
        {
            sum += x[i];
            ++i;
            ++db;
        }
        while (i<=n && x[i-1] > x[i] && sum + x[i] <= hight)
        {
            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
base32/50
1Elfogadva0/03ms1812 KiB
2Hibás válasz0/04ms2260 KiB
3Elfogadva2/22ms2132 KiB
4Hibás válasz0/22ms2112 KiB
5Elfogadva2/22ms2312 KiB
6Elfogadva2/22ms2384 KiB
7Elfogadva2/22ms2660 KiB
8Elfogadva2/22ms2792 KiB
9Elfogadva3/32ms2864 KiB
10Elfogadva2/22ms2928 KiB
11Elfogadva2/22ms3176 KiB
12Hibás válasz0/23ms3400 KiB
13Elfogadva3/34ms3748 KiB
14Hibás válasz0/34ms3724 KiB
15Elfogadva3/34ms3728 KiB
16Hibás válasz0/228ms4900 KiB
17Elfogadva3/337ms4900 KiB
18Elfogadva3/346ms5028 KiB
19Elfogadva3/329ms5100 KiB
20Hibás válasz0/330ms5304 KiB
21Hibás válasz0/329ms5372 KiB
22Hibás válasz0/334ms5452 KiB