Gift Boxes
시간 제한2초메모리 제한2048 MB
팀 번호 수열에서 하나의 연속 구간을 지워 남은 수열에 같은 팀이 두 번 나오지 않도록 할 때, 지우는 구간의 길이를 최소로 하는 구간을 찾는다.
문제
This year's EGOI is organized in Bonn. The organizers want to distribute at most one gift box to every team in the contest, with each team represented by a number from to . The contestants are standing in a single row. However they are mixed up such that people from the same team might not be standing next to each other. Note that there will be at least one team with more than one person in the row. There are people in the row. Person is part of the team . The problem is: each team should only receive a maximum of one gift box. In order to ensure the process runs smoothly - and willing to leave some teams with no gift as a consequence - the organisers wish to pause the gifting process exactly once, skipping a few contestants before resuming the gift box handouts. In other words, they will skip one consecutive segment of the contestants.
It is not necessary that every team receives a gift. Nevertheless, the organizers want to maximize the number of teams that will receive their gifts while ensuring that no team ends up with two or more gifts, equivalent to minimizing the number of contestants that are skipped under this condition. Please help the organizers to decide when it is best to pause and when to continue distributing gifts such that as few contestants as possible are skipped.
입력
The first line of input contains two integers, and -- the number of teams and the number of contestants in the row.
The second line contains integers, , where the th integer describes which team the person at position in the row belongs to. It is guaranteed that every integer between and appears at least once.
출력
Output two integers, and , where is the index of the first person that is skipped and is the index of the last skipped person. Note that and are indexed from to . If there is more than one solution, print any one of them.
제한
- .
- .