Submission #1317483

#TimeUsernameProblemLanguageResultExecution timeMemory
1317483haithamcoderInfinite Race (EGOI24_infiniterace2)C++20
51 / 100
1094 ms1992 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LOG = 31;
const ll MOD = 1000000007;
const ll inf = 1e17;
const ll B = 2305843009213693951;


#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"

#define Algerian ios::sync_with_stdio(0);
#define OI cin.tie(NULL);


int main() {
    Algerian OI

    ll n, q;
    cin >> n >> q;
    vector<ll> a(q);
    for (ll& x : a) cin >> x;

    vector<bool> ahead(n);
    ll r = 0;
    for (ll i = 0; i < q; i++) {
        if (a[i] < 0) ahead[-a[i]] = 0;
        else {
            if (ahead[a[i]]) {
                r++;
                for (ll j = 0; j < n; j++) ahead[j] = 0;
                ahead[a[i]] = 1;
            } else ahead[a[i]] = 1;
        }
    }

    cout << r << "\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...