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;
int sequence(int n, vector<int> a){
int occ[n + 1], ans = 0;
for(int i = 0; i < n; i++){
memset(occ, 0, sizeof(occ));
multiset<int> l, r;
for(int j = i; j < n; j++){
occ[a[j]]++;
if(r.empty() || a[j] <= *r.begin()) l.insert(a[j]);
else r.insert(a[j]);
if(l.size() > r.size() + 1){
r.insert(*--l.end());
l.erase(--l.end());
}
if(r.size() > l.size()){
l.insert(*r.begin());
r.erase(r.begin());
}
ans = max(ans, occ[*--l.end()]);
if(l.size() == r.size()) ans = max(ans, occ[*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... |