93082024-02-20 11:57:24AblablablaLádapakolás raktárban (50)cpp17Accepted 50/5052ms12612 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    set<int> benne;
    int osszeg = 0;
    int b = 0;
    bool jo = 1;
    int db = 1;

    for(int i = 0; i < n; i++){
        int a;
        cin >> a;

        if(!jo && a > b || a + osszeg > m || benne.count(a)){
            db++;
            jo = 1;
            benne.clear();
            osszeg = 0;
        } else{
            if(a < b) jo = 0;
        }

        b = a;
        benne.insert(a);
        osszeg += a;
    }

    cout << n - db << "\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/06ms2184 KiB
3Accepted2/23ms2308 KiB
4Accepted2/23ms2544 KiB
5Accepted2/23ms2736 KiB
6Accepted2/23ms2940 KiB
7Accepted2/23ms3024 KiB
8Accepted2/23ms3156 KiB
9Accepted3/33ms3244 KiB
10Accepted2/23ms3372 KiB
11Accepted2/23ms3600 KiB
12Accepted2/24ms3916 KiB
13Accepted3/34ms3936 KiB
14Accepted3/34ms4088 KiB
15Accepted3/36ms4216 KiB
16Accepted2/234ms4656 KiB
17Accepted3/343ms5272 KiB
18Accepted3/352ms6324 KiB
19Accepted3/337ms7228 KiB
20Accepted3/352ms10920 KiB
21Accepted3/346ms11528 KiB
22Accepted3/348ms12612 KiB