#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
unordered_map<int, int> overtakes;
unordered_map<int, int> overtaken_by;
int laps = 0;
for (int i = 0; i < Q; ++i) {
int x;
cin >> x;
if (x > 0) {
overtakes[x]++;
if (overtakes[x] > overtaken_by[x]) {
laps++;
overtakes.clear();
overtaken_by.clear();
}
} else {
x = -x;
overtaken_by[x]++;
}
}
cout << laps << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |