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 sequence(int N, std::vector<int> A) {
int mx = 0;
for (int i = 0; i < N; i++) {
map<int, int> cnt;
priority_queue<int> pql;
priority_queue<int, vector<int>, greater<int>> pqh;
for (int j = i; j < N; j++) {
int cur;
cnt[A[j]]++;
pqh.push(A[j]);
if (pqh.size() > pql.size()) {
int x = pqh.top();
pqh.pop();
pql.push(x);
}
while (!pqh.empty() && pql.top() > pqh.top()) {
int x = pql.top();
pql.pop();
int y = pqh.top();
pqh.pop();
pql.push(y);
pqh.push(x);
}
if (pql.size() == pqh.size() && pql.top() != pqh.top())
cur = max(cnt[pql.top()], cnt[pqh.top()]);
else
cur = cnt[pql.top()];
mx = max(mx, cur);
}
}
return mx;
}
# | 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... |