# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981349 | math_rabbit_1028 | Sequence (APIO23_sequence) | C++17 | 2052 ms | 35944 KiB |
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 n, m, ans = 0;
vector<int> arr, vec;
vector<int> pos[505050];
int sequence(int N, vector<int> A) {
n = N;
arr = A;
sort(A.begin(), A.end());
A.erase(unique(A.begin(), A.end()), A.end());
m = A.size();
for (int i = 0; i < n; i++) {
arr[i] = lower_bound(A.begin(), A.end(), arr[i]) - A.begin();
}
for (int i = 0; i < n; i++) {
pos[arr[i]].push_back(i);
}
for (int t = 0; t < m; t++) {
vec.clear();
for (int i = 0; i < n; i++) {
if (t == arr[i]) vec.push_back(0);
if (t > arr[i]) vec.push_back(1);
if (t < arr[i]) vec.push_back(-1);
}
for (int s = 0; s < n; s++) {
int a = 0, b = 0, c = 0;
for (int e = s; e < n; e++) {
int k = (e-s+1)/2;
if (vec[e] == -1) a++;
if (vec[e] == 0) b++;
if (a <= k && k <= a+b-(e-s+1)%2) ans = max(ans, b);
/*
-1 : a
0 : b
1 : c
합 짝수(2k ) => a <= n/2 <= a+b
합 홀수(2k+1) => a <= n/2 <= a+b-1
*/
}
}
}
return ans;
}
Compilation message (stderr)
# | 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... |