| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1341898 | marzuq01 | Gift Boxes (EGOI25_giftboxes) | C++20 | 781 ms | 78720 KiB |
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define nl '\n'
#define debun(x) cout << #x << ": " << x << "\n";
#define debug(x) cout << #x << ": " << x << " ";
const int mod = 1e9+7;
const int MOD = 998244353;
string yes = "YES";
string no = "NO";
// CODING SETTING :O
void usaco(string name) {
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
void fastIO() {
ios::sync_with_stdio(0);
cin.tie(0);
}
// GENERAL SHORTCUTS AND FUNCTIONS :D
template<typename T>
void vprint(const vector<T> &arr) {
for (auto i : arr) cout << i << " ";
cout << nl;
}
template <typename T, typename R>
void vpprint(const vector<pair<T,R>> &arr) {
for (auto i: arr) cout << "{" << i.first << "," << i.second << "} ";
cout << "\n";
}
template<typename T>
T expo(T a, T b,T m = mod) {
if (b == 0) return 1;
else if (b == 1) return a;
if (b % 2 == 0) return expo(a*a % m,b/2) % m;
else return (a*expo(a*a % m, b/2) % m) % m;
}
template<typename T>
T gcd(T a, T b) {
if (a == 0) return b;
else return gcd(b%a,a);
}
// ============< DONT TOUCH CODES ABOVE >=============
int NNN = 2000000;
int isprime[2000000];
vector<int> prime;
void thanos() {
for (int i = 0;i < NNN;i++) isprime[i] = 1;
isprime[0] = isprime[1] = 0;
for (int j = 4; j < NNN;j+=2) isprime[j] = 0;
for (int i = 3;i*i < NNN;i+=2) {
for (int j = i*i; j < NNN;j += i) isprime[j] = 0;
}
prime.pb(2);
for (int i = 3;i < NNN;i+=2) if(isprime[i]) prime.pb(i);
}
// ============< DONT also TOUCH CODES ABOVE >=============
void init() {
//thanos();
}
void solve() {
lint t,n; cin >> t >> n;
vector<lint> arr(n);
for (lint i = 0;i < n;i++) cin >> arr[i];
vector<vector<int>> pos(t);
for (int i = 0;i < n;i++) {
pos[arr[i]].pb(i);
}
int l = 0, r = n-1;
set<int> sl,sr;
while(sl.count(arr[l]) == 0) {
sl.insert(arr[l]);
l++;
}
while(sr.count(arr[r]) == 0) {
sr.insert(arr[r]);
r--;
}
l--;r++;
pair<int,int> ans = {l+1,n-1};
int cur = l+1;
//debug(l);debug(r);debun(cur);
for (int z = n-1;z >= r;z--) {
int prothom = pos[arr[z]][0];
cur = min(cur,prothom);
//debug(z);debug(prothom);debug(cur);debug(ans.first);debun(ans.second);
if (z-cur < ans.second + 1 - ans.first) {
ans = {cur,z-1};
}
}
cout << ans.first << " " << ans.second << nl;
//debug(l);debun(r);
}
int main()
{
//usaco("haybales");
fastIO();
long long int t=1;
//cin >> t;
init();
for (int aura = 0; aura < t; aura++) {
solve();
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
