eolymp
bolt
Try our new interface for solving problems
Problems

Longest Bicolored Sequence

Longest Bicolored Sequence

Given the stripe $1 \cdot n$ cells. Each cell is colored by one of $10^4$ colors. The cells are enumerated from leftmost to rightmost one by sequential integers between $1$ and $n$, inclusively. Your task is to find the longest continuous sequence of the cells such that total number of colors in that sequence does not exceed $2$. If there are more than one longest sequence, print the leftmost of them. \InputFile The first line contains one integer $n~(1 \le n \le 10^5)$ --- the length of the stripe. The second line contains $n$ integers $c_i~(1 \le c_i \le 10^4)$ --- the colors of the cells, listed from leftmost one to rightmost one. The cells of the same color are denoted by the same integer, the cells that have distinct colors --- by $d_i$ different integers. \OutputFile Print two integers --- the number of the cell where the longest continuous sequence that contains the cells of no more than two colors starts, and the length of this sequence. If there are more than one solutions, print one with the smallest first value (i.e. the leftmost one).
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
2 2 2 2 2
Output example #1
1 5
Input example #2
5
10 8 3 600 6
Output example #2
1 2
Input example #3
8
3 3 3 2 1 1 1 1
Output example #3
4 5
Source 2022 Azerbaijan ICPC Qualification