Submission #1243029

#TimeUsernameProblemLanguageResultExecution timeMemory
1243029dxh074Infinite Race (EGOI24_infiniterace2)C++20
100 / 100
306 ms632 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n, q, x, ans = 0;
    cin >> n >> q;
    bool b[n]{};

    while(q--)
    {
        cin >> x;
        if (x < 0)
            b[-x] = false;
        else
        {
            if (b[x]) {
                ++ans;
                memset(b, false, sizeof(b));
            }
            b[x] = true;
        }
    }
    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...