#include <iostream>
#include <set>
using namespace std;
int main()
{
int n,q; int a[300000]; int cnt=0;
set<int> s;
cin>>n;
cin>>q;
int f[300000] = {0};
for(int i=1; i<=q; i++){cin>>a[i];}
for(int i=1; i<=q; i++){
if(a[i]>0){
if(s.find(a[i]) == s.end()){
s.insert(a[i]);
}
else {
cnt++;
s.clear();
s.insert(a[i]);
}
}
else {
s.erase(-a[i]);
}
}
cout<<cnt;
}
# | 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... |