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;
int ct[500005];
priority_queue<int> le;
priority_queue<int, vector<int>, greater<int>> ri;
int sequence(int N, std::vector<int> A) {
int ret = 0;
for(int l=0;l<N;l++) {
while(!le.empty()) ct[le.top()]--, le.pop();
while(!ri.empty()) ct[ri.top()]--, ri.pop();
for(int r=l;r<N;r++) {
if(le.empty() || A[r]<=le.top()) le.push(A[r]);
else ri.push(A[r]);
if(le.size()>ri.size()+1) {
ri.push(le.top());
le.pop();
}
if(ri.size()>le.size()) {
le.push(ri.top());
ri.pop();
}
ct[A[r]]++;
ret = max(ret, ct[le.top()]);
if(le.size()==ri.size()) ret = max(ret, ct[ri.top()]);
}
}
return ret;
}
# | 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... |