#include <iostream>
using namespace std;
int main()
{
int n,q; int a[300000]; int mx[300000] = {0};
cin>>n;
cin>>q;
int cnt[300000] = {0};
for(int i=1; i<=q; i++){cin>>a[i];}
for(int i=q; i>=1; i--){
if(a[i]>0){cnt[a[i]] ++; mx[a[i]] = max(mx[a[i]], cnt[a[i]]);}
else {cnt[-a[i]]--;}
}
int ok=0;
for(int i=1; i<n; i++){ok = max(ok, mx[i] -1);}
cout<<ok;
}
# | 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... |