|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|2 초||512 MB||96||84||80||87.912%|
Mount Marathon is a solitaire game that is played using a regular deck of 52 cards. To start the game the player shuffles the deck and lays N cards face up on the table, forming a straight line of N piles, each pile having a single card. No other cards are used during the rest of the play. Then the player repeatedly moves a pile on top of another pile until no more movements are available. The goal of the game is to end up with the minimum number of piles. When moving a pile p on top of another pile q, the following conditions must hold:
Figure (a) below shows a configuration with six cards at the beginning of the game. The player may move the fifth pile on top of the sixth pile, and then the second pile on top of the third pile; since no more movements are available, this would conclude the game with four piles remaining, as it can be seen in figure (b). However, in this case it is possible to end up the game with just the three piles that appear in figure (c).
Given the initial piles, you must determine the minimum number of piles that it is possible to obtain at the end of the game.
The first line contains an integer N (1 ≤ N ≤ 52) representing the number of cards in the game. The second line contains N integers C1, C2, . . . , CN (1 ≤ Ci ≤ 13 for i = 1, 2, . . . , N) indicating the values of the cards in the initial piles, from left to right. Each card value appears at most four times.
Output a single line with an integer indicating the minimum number of piles that it is possible to obtain at the end of the game.
6 5 8 6 6 10 4
5 2 4 6 8 10
11 13 1 1 1 13 7 8 10 4 2 1