| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1356280 | kawhiet | Sequence (APIO23_sequence) | C++20 | 81 ms | 31552 KiB |
#include <bits/stdc++.h>
#include "sequence.h"
using namespace std;
int sequence(int n, vector<int> a) {
vector<vector<int>> pos(n + 1);
for (int i = 0; i < n; i++) {
pos[a[i]].push_back(i);
}
int ans = 0;
for (int x = 1; x <= n; x++) {
if (pos[x].empty()) continue;
vector<int> s;
int c = 1;
for (int i = 1; i < pos[x].size(); i++) {
if (pos[x][i] == pos[x][i - 1] + 1) {
c++;
} else {
s.push_back(c);
c = 1;
}
}
s.push_back(c);
if (s.size() == 2) {
int t = s[0] + s[1];
int len = pos[x].back() - pos[x][0] + 1;
if (2 * t >= len) {
ans = max(ans, t);
}
}
ans = max(ans, ranges::max(s));
}
return ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
