제출 #1129634

#제출 시각아이디문제언어결과실행 시간메모리
1129634c0det1gerInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
76 ms11352 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
 
#define int long long
#define bochi_orz cin.tie(0);cin.sync_with_stdio(0);

signed main() {
    bochi_orz
    int n, q;
    cin >> n >> q;
    vector<int> queries(q);
    set<int> st;
    int cnt = 0;
    for (int i = 0; i < q; i++){
        int x;
        cin >> x;
        if (x > 0){
            if (st.find(x) != st.end()){
                st.clear();
                cnt++;
            }
            st.insert(x);
        }
        else{
            if (st.find(-x) != st.end()){
                st.erase(-x);
            }
        }
    }
    cout << cnt << "\n";
}
 
/*
 ____   ___    ___     ____  _____          ____    ____   ___
|      |   |  |   \   |        |     /|    |       |      |   \
|      |   |  |    |  |____    |      |    |   _   |____  |___/
|      |   |  |    |  |        |      |    |    |  |      |  \
|____  |___|  |___/   |____    |    __|__  |____|  |____  |   \
 
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...