2752.Amr and The Large Array

Time Limit: 1s Memory Limit: 256MB

Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.

Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subsegment of this array such that the beauty of it will be the same as the original array.

Help Amr by choosing the smallest subsegment possible.

Input Format(From the terminal/stdin)

The first line contains one number n (1 \le n \le 105), the size of the array.

The second line contains n integers ai (1 \le ai \le 106), representing elements of the array.

Output Format(To the terminal/stdout)

Output two integers l,r (1 \le l \le r \le n), the beginning and the end of the subsegment chosen respectively.

If there are several possible answers you may output any of them.

Sample Input 1

Copy
5
1 1 2 2 1
 \n
 · · · · \n

Sample Output 1

Copy
1 5
 · \n

Sample Input 2

Copy
5
1 2 2 3 1
 \n
 · · · · \n

Sample Output 2

Copy
2 3
 · \n

Sample Input 3

Copy
6
1 2 2 1 1 2
 \n
 · · · · · \n

Sample Output 3

Copy
1 5
 · \n

Hints

A subsegment B of an array A from l to r is an array of size r-l+1 where Bi=Al+i-1 for all 1 \le i \le r-l+1

Submit

请先 登录

© 2025 FAQs