| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332764 | dusky | Gift Boxes (EGOI25_giftboxes) | C++20 | 110 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 = 1e9, l = 0, r = 0, skip = 0;
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);
}컴파일 시 표준 에러 (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... | ||||
