제출 #1342978

#제출 시각아이디문제언어결과실행 시간메모리
1342978nathlol2Infinite Race (EGOI24_infiniterace2)C++20
100 / 100
16 ms2120 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, q, ans, f[N];
vector<int> a[N], ff;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> q;
    for(int i = 1;i<=q;i++){
        int x; cin >> x;
        if(x > 0){
            if(f[x]){
                while(ff.size()) f[ff.back()] = 0, ff.pop_back();
                f[x] = 1;
                ff.push_back(x);
                ++ans;
            }
            else f[x] = 1, ff.push_back(x);
        }else{
            if(f[-x]) f[-x] = 0;
        }
    }
    cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...