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 "sequence.h"
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>pql;
priority_queue<int,vector<int>,greater<>>pqu;
multiset<int>st2;
void balance(){
if(pql.size()<pqu.size())
pql.push(pqu.top()),pqu.pop();
if(pql.size()-pqu.size()>1)
pqu.push(pql.top()),pql.pop();
}
int sequence(int N, std::vector<int> A) {
int ans=1;
for(int i=0;i<N;i++){
st2.clear();
while(pql.size())
pql.pop();
while(pqu.size())
pqu.pop();
pql.push(A[i]);
st2.insert(A[i]);
for(int j=i+1;j<N;j++) {
if(A[j]<=pql.top())
pql.push(A[j]);
else pqu.push(A[j]);
balance();
st2.insert(A[j]);
int a=pql.top();
int b=(pql.size()==pqu.size()?pqu.top():a);
ans=max(ans,(int)st2.count(a));
ans=max(ans,(int)st2.count(b));
}
}
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... |