제출 #1239698

#제출 시각아이디문제언어결과실행 시간메모리
1239698AMel0nInfinite Race (EGOI24_infiniterace2)C++17
100 / 100
13 ms1864 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define FOR(i,N) for(ll i = 0; i < N; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second


signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    vector<ll> overtaken(N, -1);
    ll lap = 0;
    FOR(i, Q) {
        ll p;
        cin >> p;
        if (p > 0) {
            if (overtaken[p] != lap) overtaken[p] = lap;
            else {
                lap++;
                overtaken[p] = lap;
            }
        } else {
            overtaken[-p] = -1;
        }
    }
    cout << lap;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...