제출 #1165473

#제출 시각아이디문제언어결과실행 시간메모리
1165473Tony1234Infinite Race (EGOI24_infiniterace2)C++20
100 / 100
64 ms9872 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef _debug 
#include </home/tony/templates/debug.cpp>
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define vi vector<int>
#define vt vector
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MOD = 1e9 + 7, inf = (int)2e9;
const ll infll = (ll)1e18;

void solve(){
    int n,m;cin >> n >> m;
    set<int> s;
    int a = 0;
    for(int i = 0; i < m; i++){
        int u; cin >> u;
        if(u < 0){
            s.erase(-u); 
        }else{
            if(s.count(u))a++, s = {u};
            else s.insert(u); 
        }
    }
    cout << a << '\n';
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    solve();
}




#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...