# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
974307 | Pannda | Sequence (APIO23_sequence) | C++17 | 106 ms | 33516 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 sequence(int n, vector<int> a) {
vector<vector<int>> mp(n);
for (int i = 0; i < n; i++) {
a[i]--;
mp[a[i]].push_back(i);
}
int ans = 0;
for (int i = 0, c; i < n; i++) {
if (i == 0 || a[i] != a[i - 1]) {
c = 1;
} else {
c++;
}
ans = max(ans, c);
}
for (int med = 0; med < n; med++) {
if (mp[med].size() < 2) continue;
int l = mp[med].front();
int r = mp[med].back() + 1;
if (2 * (n - r + l + mp[med].size()) >= n) {
ans = max(ans, (int)mp[med].size());
}
}
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... |