제출 #1166630

#제출 시각아이디문제언어결과실행 시간메모리
1166630hamzabcInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
13 ms1096 KiB
#include <bits/stdc++.h>

using namespace std;
 
 
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define sp << " " <<
#define endl << '\n'


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int N, Q;
    cin >> N >> Q;
    vector<int> part2(N);
    int ret = 0;
    int s = 1;
    for (int i = 0; i < Q; i++){
        long long int K;
        cin >> K;
        if (K < 0){
            part2[-K] = 0;
        }else{
            if (part2[K] == s){
                ret++;
                s++;
                part2[K] = s;
            }else
                part2[K] = s;
        }
    }
    cout << ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...