27132023-01-19 11:05:22bzsofiaLádapakolás raktárban (50)cpp11Wrong answer 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
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/03ms1812 KiB
2Wrong answer0/04ms2260 KiB
3Accepted2/22ms2132 KiB
4Wrong answer0/22ms2112 KiB
5Accepted2/22ms2312 KiB
6Accepted2/22ms2384 KiB
7Accepted2/22ms2660 KiB
8Accepted2/22ms2792 KiB
9Accepted3/32ms2864 KiB
10Accepted2/22ms2928 KiB
11Accepted2/22ms3176 KiB
12Wrong answer0/23ms3400 KiB
13Accepted3/34ms3748 KiB
14Wrong answer0/34ms3724 KiB
15Accepted3/34ms3728 KiB
16Wrong answer0/228ms4900 KiB
17Accepted3/337ms4900 KiB
18Accepted3/346ms5028 KiB
19Accepted3/329ms5100 KiB
20Wrong answer0/330ms5304 KiB
21Wrong answer0/329ms5372 KiB
22Wrong answer0/334ms5452 KiB