This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ss second
#define pb push_back
#define mod 1000000007
#define N 200005
#define INF 1000000000000000005
#define pu push
#define ff first
#define pint pair<int,int>
typedef long long ll;
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int t;
cin>>t;
bool take[n];
int cnt[n],ans=0;
set<int> st;
memset(cnt,0,sizeof(cnt));
memset(take,false,sizeof(take));
while(t--)
{
int a;
cin>>a;
if(a>0)
{
if(take[a]&&(st.size()==0||st.count(a))){
st.insert(a);
cnt[a]++;
}
else if(st.count(a))
{
st.clear();
st.insert(a);
}
else if(!take[a]){
st.clear();
take[a]=true;
}
}
else{
st.clear();
take[-a]=false;
}
}
for(int i=1;i<n;i++)
ans=max(ans,cnt[i]);
cout<<ans<<endl;
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... |