P1638 Visiting the Art Exhibition

Description

The exhibition hall is displaying paintings by the world’s best $m$ painters. When buying a ticket, a visitor must specify two numbers, $x$ and $y$, meaning they want to see all paintings from the $x$-th to the $y$-th (inclusive), and the ticket price is one yuan per painting. Sept hopes that, after entering, he can see paintings by all the master painters. Of course, he wants to minimize the ticket price. Find the $x, y$ he should choose when buying the ticket. The testdata guarantees that a solution exists. If multiple solutions exist, **output the one with the smallest $x$**.

Input Format

The first line contains two integers $n, m$, denoting the total number of paintings in the exhibition and the number of master painters, respectively. The second line contains $n$ integers $a_i$, where $a_i$ is the ID of the master who painted the $i$-th painting.

Output Format

One line with two integers $x, y$.

Explanation/Hint

#### Constraints - For 30% of the testdata, $n \le 200$, $m \le 20$. - For 60% of the testdata, $n \le 10^5$, $m \le 10^3$. - For 100% of the testdata, $1 \le n \le 10^6$, $1 \le a_i \le m \le 2 \times 10^3$. Translated by ChatGPT 5