| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1332765 | dusky | Gift Boxes (EGOI25_giftboxes) | C++20 | 113 ms | 30256 KiB |
#include <bits/stdc++.h>
using namespace std;
bool inl[500005]; int a[500005]; vector<int> pos[500005];
int main() {
// freopen("in.txt", "r", stdin);
int t, n; scanf("%d %d", &t, &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
pos[a[i]].push_back(i);
}
priority_queue<pair<int, int>> conflict;
for (int i = 0; i < t; i++) {
if (pos[i].size() == 1) continue;
conflict.push({pos[i][pos[i].size()-2], i});
}
int ans = conflict.top().first, l = 0, r = conflict.top().first, skip = conflict.top().first;
for (int i = 0; i < n; i++) {
int x = a[i];
if (inl[x]) break;
inl[x] = true; skip = max(skip, pos[x].back());
while (!conflict.empty() && inl[conflict.top().second]) conflict.pop();
if (conflict.size()) skip = max(skip, conflict.top().first);
if (skip-i-1 < ans) { ans = skip-i; l = i+1; r = skip; }
} printf("%d %d\n", l, r);
}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... | ||||
