43882023-03-27 12:11:33ZsofiaKeresztelyLádapakolás raktárban (50)cpp14Wrong answer 32/5016ms4736 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, piles = 1, sum=0, a, b = 0;
    bool up = true;
    cin >> n >> m;
    for (int i=0; i<n; i++){
        cin >> a;
        if (sum + a > m || a == b || !up && a > b){
            sum = a;
            up = true;
            piles++;
        }
        else{
            sum += a;
            if (a < b) up = false;
        }
        b = a;
    }
    cout << n - piles;
}
SubtaskSumTestVerdictTimeMemory
base32/50
1Accepted0/03ms1892 KiB
2Wrong answer0/03ms2120 KiB
3Accepted2/22ms2604 KiB
4Wrong answer0/23ms2656 KiB
5Accepted2/23ms2760 KiB
6Accepted2/23ms2896 KiB
7Accepted2/22ms2984 KiB
8Accepted2/22ms2984 KiB
9Accepted3/33ms3152 KiB
10Accepted2/23ms3388 KiB
11Accepted2/22ms3440 KiB
12Wrong answer0/23ms3576 KiB
13Accepted3/33ms3780 KiB
14Wrong answer0/33ms3996 KiB
15Accepted3/34ms4216 KiB
16Wrong answer0/212ms4308 KiB
17Accepted3/314ms4424 KiB
18Accepted3/316ms4640 KiB
19Accepted3/310ms4732 KiB
20Wrong answer0/310ms4732 KiB
21Wrong answer0/310ms4736 KiB
22Wrong answer0/312ms4736 KiB