이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sequence.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int sequence(int n, std::vector<int> a) {
ll mx = 0;
for (int i = 0; i < n; ++i)
{
map < int, ll > m;
int mid = -1, mi = 0;
for (int j = i; j >= 0; --j)
{
++m[a[j]];
if (mid == -1) mid = a[j];
if (a[j] < mid) ++mi;
if ((i - j + 1) / 2 < mi) mid = prev (m.find (mid))->first, mi -= m[mid];
if (mi + m[mid] <= (i - j + 1) / 2) mi += m[mid], mid = next (m.find (mid))->first;
ll ans = m[mid];
if (mi + m[mid] <= (i - j + 2) / 2)
ans = max (ans, next (m.find (mid))->second);
mx = max (mx, ans);
}
}
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... |