Logo
(追記) (追記ここまで)

21876번 - Squarow 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB181817100.000%

문제

Moris's favorite computer game is called <<Squarow>>. The game starts with a row of colored squares appearing on the screen. The player can choose a color and remove all the squares of that color (you cannot choose a color that is not among the colors of the squares). After removal, all remaining squares are shifted to the left so that there are no empty spaces in the row between adjacent squares. The order of the squares in the row does not change. All squares of the same color, standing in a row one after another, form a \emph {block}. When you remove a selected color, you get the number of points equal to the number of blocks left in the row.

Help Moris find out what is the largest number of blocks he can get after removing the squares of some color, and what color to choose. If there are several such colors, output any of them.

입력

The first line contains a single integer $n$ (1ドル \le n \le 2 \cdot 10^5$), the number of squares in the row.

The second line contains $n$ integers $a_i$ (1ドル \le i \le n,ドル 1ドル \le a_i \le 2 \cdot 10^5$), the color of the $i$-th square in the row.

출력

In a single line output two integers: the largest number of blocks that can remain after removing all the squares of one chosen color, and the number corresponding to the color that must be removed to achieve such a number of blocks.

제한

서브태스크

번호배점제한
119

$n \le 100,ドル $a_i \le 100$

243

$n \le 10^4,ドル $a_i \le 10^3$

338

$n \le 2 \cdot 10^5,ドル $a_i \le 2 \cdot 10^5$

예제 입력 1

6
1 1 1 2 2 1

예제 출력 1

1 1

예제 입력 2

12
1 1 2 3 3 3 2 1 1 1 2 2

예제 출력 2

4 3

예제 입력 3

15
4 5 5 4 4 4 5 9 9 5 5 5 5 9 9

예제 출력 3

4 4

힌트

In the first example, if you remove color 1, one block of color 2 will remain, and if you remove color 2, there will be one block of color 1 (since the blocks on opposite sides of the block of color 2 will merge into one block).

In the second example, if you remove color 1, there will be three blocks, if you remove color 2, there will be also three blocks, and if you remove color 3, then 4 blocks will remain.

In the third example: for color 4 : 4 blocks, for color 5 : 2 blocks, for color 9 : 4 blocks.

출처

Contest > Innopolis Open in Informatics > Innopolis Open, First elimination round, 2018-2019 B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /