| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1368545 | hahaha | Gift Boxes (EGOI25_giftboxes) | C++20 | 75 ms | 8264 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
const int N=5e5+7;
int n,t;
vector<int>a;
int f[N];
signed main(){
cin>>t>>n;
int mx=0;
for(int i=0; i<n; i++){
int x;
cin>>x;
a.pb(x);
}
int l=0;
int r=0;
int ans=N, ansl, ansr;
int gstdif=0;
int stpr=-1;
while (gstdif<t&&r<n) {
if (f[a[r]]==0) gstdif++;
else if (stpr==-1) stpr=r;
f[a[r]]++;
r++;
}
if (stpr==-1)stpr=r;
r--;
if(ans>r-l+1) {
ans=r-l+1;
ansl=l;
ansr=r;
};
while (l<stpr) {
l++;
f[a[l-1]]--;
while(f[a[l-1]]==0&&r<n-1){
r++;
f[a[r]]++;
}
if(ans>r-l+1) {
ans=r-l+1;
ansl=l;
ansr=r;
};
}
cout<<ansl<<" "<<ansr<<endl;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
