#include <iostream>
#include <iomanip>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define dbg(x) cerr<<#x<<": "<<x<<"\n";
/*
Seventh Heaven
INOHA
*/
void solve(){
int n, q; cin>>n>>q;
map<int, pair<bool, bool>>mp;
map<int, int>ans;
for(int i=0 ; i<=n ; i++) mp[i].second=1;
int aux=0;
for(int i=0 ; i<q ; i++){
int curr; cin>>curr;
if(curr<0){
curr=-curr;
if(mp[curr].second==1) ans[curr]=ans[curr]+1;
// aux=max(aux, ans[curr]);
mp[curr].second=1;
mp[curr].first=0;
}else{
if(mp[curr].first==1) ans[curr]=ans[curr]+1;
aux=max(aux, ans[curr]);
mp[curr].second=0;
mp[curr].first=1;
}
}
cout<<aux<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
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... |