제출 #1342320

#제출 시각아이디문제언어결과실행 시간메모리
1342320mantaggezInfinite Race (EGOI24_infiniterace2)C++20
100 / 100
15 ms1216 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx = 2e5+5;

int n, q, ans;
int b[nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> q;
    fill(b, b + nx, -1);
    while(q--) {
        int x; cin >> x;
        int idx = abs(x);

        if(x > 0) {
            if(b[idx] != ans) b[idx] = ans;
            else ans++, b[idx] = ans;
        }
        else {
            if(b[idx] == ans) b[idx] = -1;
        }
    }

    cout << ans << '\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...