이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |