| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1342167 | gry3125 | Gift Boxes (EGOI25_giftboxes) | C++20 | 498 ms | 27812 KiB |
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
using namespace std;
int main() {
int t, n; cin >> t >> n;
vector<int> a(n); set<int> s;
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> rg(t);
for (int i = 0; i < n; i++) {
rg[a[i]] = max(rg[a[i]], i);
}
int AL = -1, AR = -1, mx = 0;
int R = n-1;
// suffix only
for (int i = n-1; i >= 0; i--) {
s.insert(a[i]);
if (s.size() != n-i) {
R = i; break;
}
}
if (mx < n-1-R) {
mx = n-1-R;
AL = 0; AR = R;
}
s.clear();
for (int i = 0; i < n; i++) {
s.insert(a[i]);
if (s.size() != i+1) break;
R = max(R, rg[a[i]]);
int sz = n-(R-i);
if (mx < sz) {
mx = sz;
AL = i+1; AR = R;
}
}
cout << AL << " " << AR;
return 0;
}| # | 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... | ||||
