Submission #1121356

#TimeUsernameProblemLanguageResultExecution timeMemory
1121356AMel0nInfinite Race (EGOI24_infiniterace2)C++17
100 / 100
21 ms3408 KiB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(N) for(int i=0;i<N;++i)
#define ll long long
#define int long long
#define pi pair<int,int>
#define vi vector<int>
//#define F first
//#define S second
#define gotta_go_fast cin.tie(0); ios_base::sync_with_stdio(0);


// EGOI 2024 D1 Q1 Infinite Race

signed main() {
    gotta_go_fast
    int N, Q;
    cin >> N >> Q;

    vi pos(N, -1);

    int laps = 0;
    rep(Q) {
        int P;
        cin >> P;
        if (P > 0) {
            if (pos[P] == laps) {
                laps++;
                pos[P] = laps;
            } else pos[P] = laps;
        } else pos[-1 * P] = -1;
    }
    cout << laps;
    
   
    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...