#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,q,ans=0,x;
cin >> n >> q;
vector <int> a(q);
vector <int> b(q);
while(q--){
cin >> x;
if(x<0){
b[-x]=0;
a[-x]=max(a[-x],ans);
}
else{
if(b[x]==1){
a[x]=max(a[x], ans-1);
a[x]++;
ans=max(ans, a[x]);
}
b[x]=1;
}
}
cout << ans << "\n";
}
# | 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... |