#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n,q;
cin>>n>>q;
set<int>st;
int ans=0;
for(int i=1;i<=q;i++){
int x;
cin>>x;
if(x>0){
if(st.count(x)==0){
st.insert(x);
}
else{
ans++;
st.clear();
st.insert(x);
}
}
else{
x=-x;
if(st.count(x)==1){
st.erase(x);
}
}
}
cout<<ans;
}
# | 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... |