| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1360213 | kawhiet | Gift Boxes (EGOI25_giftboxes) | C++20 | 88 ms | 6308 KiB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t, n;
cin >> t >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> cnt(t);
for (int i = 0; i < n; i++) {
cnt[a[i]]++;
}
auto get = [&](int k) {
vector<int> f = cnt;
int res = t - count(f.begin(), f.end(), 0) - count(f.begin(), f.end(), 1);
for (int i = 0; i < k; i++) {
f[a[i]]--;
if (f[a[i]] == 1) {
res--;
}
}
if (res == 0) {
return k - 1;
}
for (int i = k; i < n; i++) {
f[a[i]]--;
if (f[a[i]] == 1) {
res--;
}
f[a[i - k]]++;
if (f[a[i - k]] == 2) {
res++;
}
if (res == 0) {
return i;
}
}
return -1;
};
int l = -1, r = n;
pair<int, int> ans;
while (l + 1 < r) {
int m = (l + r) / 2;
int x = get(m);
if (x != -1) {
ans = {x - m + 1, x};
r = m;
} else {
l = m;
}
}
cout << ans.first << ' ' << ans.second << '\n';
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... | ||||
