#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, q, x;
signed main() {
cin >> n >> q;
set<int> g;
int count =0;
for (int i=0; i<q; i++){
cin >> x;
if(x>0){
if(g.count(-x)!=0)g.erase(-x);
else if(g.count(x)>0){
g.clear();
count++;
}
g.insert(x);
}
else g.insert(x);
}
cout << count << endl;
}
# | 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... |