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>
#include "sequence.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 sequence(int n,vector<int>A){
int ans=1;
int cnt[n+1];
for(int i=0;i<n;i++){
fill(cnt,cnt+n+1,0);
multiset<int,greater<int>>l;
multiset<int>r;
for(int j=i;j<n;j++){
cnt[A[j]]++;
if(l.size()==r.size()){
if(l.size()==0||A[j]>=*r.begin()){
r.insert(A[j]);
}
else{
int x=*l.begin();
r.insert(x);
l.erase(l.find(x));
l.insert(A[j]);
}
if(i!=j){
ans=max(ans,cnt[*r.begin()]);
}
}
else{
if(A[j]<=*r.begin()){
l.insert(A[j]);
}
else{
int x=*r.begin();
l.insert(x);
r.erase(r.find(x));
r.insert(A[j]);
}
ans=max({ans,cnt[*l.begin()],cnt[*r.begin()]});
}
}
}
return 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |