제출 #1344513

#제출 시각아이디문제언어결과실행 시간메모리
1344513goulthenInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
66 ms9700 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,a,b) for (int i = a; i >= b; i--)
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define endl '\n'

const int MAXN = 2e5+10;
const int INF = 1e18+10;
const int MOD = 1e9+7;

void solve() {
    int n,q;cin >> n >> q;
    int ans = 0;
    set<int> st;
    rep(i,1,q) {
        int x; cin >> x;
        if(x<0) {
            st.erase(-x);
            continue;
        }
        if (st.find(x) != st.end()) {
            ans++;
            st.clear();
        } 
        st.insert(x);
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    int tt = 1;
    //cin >> tt;

    while (tt--) solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...