```
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int N=1e6+10;
int a,b,p[N];
int last[N];
priority_queue<int,vector<int>,greater<int>>lengthl;
int main(){
scanf("%d %d",&a,&b);
for(int i=1;i<=a;i++){
scanf("%d",&p[i]);
}
for(int i=1;i<=a;i++){
int size=1;
int sta[b+1]={0};
sta[p[i]]=1;
for(int j=i+1;j<=a;j++){
if(sta[p[j]]==0){
size++;
sta[p[j]]=1;
}
if(size==b){
last[i]=j;
int length=last[i]-i+1;
lengthl.push(length);
break;
}
}
}
for(int i=1;i<=a;i++){
//检验:
//printf("%d %d %d %d\n",i,last[i],last[i]-i,lengthl.top());
if(last[i]-i+1==lengthl.top()){
printf("%d %d",i,last[i]);
break;
}
}
return 0;
}
```
by Celestinefly @ 2024-04-05 11:42:20