#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2039 ms |
4764 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |