이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sequence.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int sequence(int N, std::vector<int> a) {
int ans = 0;
for (int i = 0; i < N; i++) {
priority_queue<int> front;
priority_queue<int, vector<int>, greater<int>> back;
map<int, int> cnt;
for (int j = i; j < N; j++) {
front.push(a[j]);
cnt[a[j]]++;
while (front.size() - back.size() >= 2) {
back.push(front.top());
front.pop();
}
while (back.size() && front.top() > back.top()) {
int A = front.top(); front.pop();
int B = back.top(); back.pop();
back.push(A); front.push(B);
}
if (front.size() == back.size()) {
int m1 = front.top();
int m2 = back.top();
ans = max(ans, cnt[m1]);
ans = max(ans, cnt[m2]);
}
else {
int m1 = front.top();
ans = max(ans, cnt[m1]);
}
}
}
return ans;
}
// #include "grader.cpp"
# | 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... |