#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define INF 2139062143
using namespace std;
const int MAX = 1001000;
int n;
int l[MAX],r[MAX],sum[MAX];
int main()
{
while(cin>>n)
{
memset(sum,0,sizeof(sum));
memset(l,INF,sizeof(l));
memset(r,-INF,sizeof(r));
int w;
for(int i = 1;i <= n;i ++)
{
scanf("%d",&w);
l[w] = min(l[w],i);
r[w] = max(r[w],i);
sum[w] ++;
}
int Max = -1,ans = INF,bb = 0;
for(int i = 1;i <= MAX;i ++)
Max = max(sum[i],Max);
for(int i = 1;i <= MAX;i ++)
{
if(Max == sum[i]&& ans > r[i]-l[i]+1)
{
ans = r[i]-l[i]+1;
bb = i;
}
}
printf("%d %d\n",l[bb],r[bb]);
}
//cout << "Hello world!" << endl;
return 0;
}
CF 558B Amr and The Large Array
最新推荐文章于 2024-06-05 18:00:22 发布