| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1357652 | edo | Gift Boxes (EGOI25_giftboxes) | C++20 | 25 ms | 5124 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, t;
cin >> t >> n;
vector<int> a(n), pos(t);
for (int i = 0; i < n; ++i) {
cin >> a[i];
pos[a[i]] = i;
}
pair<int, int> ans = {0, n - 1};
int r = n - 1;
vector<char> f(t, 0);
for (int i = n - 1; ~i; i--) {
if (f[a[i]])
break;
f[a[i]] = 1;
r = i - 1;
}
vector<char>(t, 0).swap(f);
for (int i = 0; i < n; ++i) {
if (f[a[i]])
break;
f[a[i]] = 1;
int l = i + 1;
r = max(r, pos[a[i]]);
if (r - l < ans.second - ans.first)
ans = {l, r};
}
cout << ans.first << " " << ans.second;
return 0;
}
| # | 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... | ||||
