88982024-02-03 11:17:20hackemonLádapakolás raktárban (50)cpp17Wrong answer 4/5026ms10108 KiB
#include <bits/stdc++.h>
using namespace std;


int main() {
    //freopen("be1.txt", "r", stdin);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n >> m;


    vector<int> k(n); 
    int ans = 0; 

    for(int i = 0;i < n;i++ ) {
        cin >> k[i];
    }
    
    set<int> f;
    f.insert(k[0]); 
    int counter = 1; 

    bool increasing = true;

    for(int i = 1;i < n;i++ ) { 
        if(f.find(k[i]) != f.end()) {
            f.clear();
            counter++;
            f.insert(k[i]);
        } else if(k[i] < k[i-1]) {
            if(increasing) {
                increasing = false; 
            } else { 
                f.clear();
                counter++;
                increasing = true;
            }
            f.insert(k[i]);
        } else {
            if(!increasing) {
                f.clear();
                counter++;
                increasing = true;
            }
            f.insert(k[i]);
        }
    }

    cout << n - counter << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/03ms2104 KiB
2Wrong answer0/04ms2488 KiB
3Wrong answer0/23ms2488 KiB
4Wrong answer0/23ms2552 KiB
5Wrong answer0/23ms2636 KiB
6Accepted2/23ms2764 KiB
7Accepted2/22ms2740 KiB
8Wrong answer0/22ms2748 KiB
9Wrong answer0/33ms2848 KiB
10Wrong answer0/23ms2912 KiB
11Wrong answer0/23ms3052 KiB
12Wrong answer0/23ms3200 KiB
13Wrong answer0/33ms3280 KiB
14Wrong answer0/34ms3500 KiB
15Wrong answer0/34ms3696 KiB
16Wrong answer0/217ms4920 KiB
17Wrong answer0/319ms5552 KiB
18Wrong answer0/323ms6728 KiB
19Wrong answer0/323ms8872 KiB
20Wrong answer0/326ms9232 KiB
21Wrong answer0/323ms9616 KiB
22Wrong answer0/323ms10108 KiB