codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

558B.md (1449B)


      1 Source: https://codeforces.com/problemset/problem/558/B
      2 
      3 B. Amr and The Large Array
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Amr has got a large array of size *n*. Amr doesn't like large arrays so he intends to make it smaller.
     22 
     23 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.
     24 
     25 Help Amr by choosing the smallest subsegment possible.
     26 
     27 Input
     28 
     29 The first line contains one number *n* (1 ≤ *n* ≤ 105), the size of the array.
     30 
     31 The second line contains *n* integers *a**i* (1 ≤ *a**i* ≤ 106), representing elements of the array.
     32 
     33 Output
     34 
     35 Output two integers *l*, *r* (1 ≤ *l* ≤ *r* ≤ *n*), the beginning and the end of the subsegment chosen respectively.
     36 
     37 If there are several possible answers you may output any of them.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 5  
     45 1 1 2 2 1
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 1 5
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 5  
     58 1 2 2 3 1
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 2 3
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 6  
     71 1 2 2 1 1 2
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 1 5
     78 ```
     79 
     80 Note
     81 
     82 A subsegment *B* of an array *A* from *l* to *r* is an array of size *r* - *l* + 1 where *B**i* = *A**l* + *i* - 1 for all 1 ≤ *i* ≤ *r* - *l* + 1