Submission #1344756

#TimeUsernameProblemLanguageResultExecution timeMemory
1344756walizamaneeInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
189 ms19212 KiB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int boro = 200005;
ll vag = 1000000007;

int n ,q , one , two , tim[boro];
    
set<int> shamne , pichone;

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

    

    cin >> n >> q;
    for( int z = 1; z < n; z++ ) shamne.insert(z);
    two = 0;
    for( int z = 0; z < q; z++ ){
        cin >> one;

        if( one < 0 ){
            one = one * (-1);
            pichone.erase(one);
            shamne.insert(one);
        }
        else{
            if( shamne.find(one) != shamne.end() ){
                shamne.erase(one);
                pichone.insert(one);
            }
            else{
                for( auto it : pichone ) shamne.insert(it);
                pichone.clear();
                shamne.erase(one);
                pichone.insert(one);

                two++;
            }
        }

    }

    cout << two << "\n";

    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...