문제
Having become bored with standard 2-dimensional artwork (and also frustrated at others copying her work), the great bovine artist Picowso has decided to switch to a more minimalist, 1-dimensional style. Her latest painting can be described by a 1-dimensional array of colors of length (), where each color is specified by an integer in the range .
To Picowso's great dismay, her competitor Moonet seems to have figured out how to copy even these 1-dimensional paintings! Moonet will paint a single interval with a single color, wait for it to dry, then paint another interval, and so on. Moonet can use each of the colors as many times as she likes (possibly none).
Please compute the number of such brush strokes needed for Moonet to copy Picowso's latest 1-dimensional painting.
입력
The first line of input contains .
The next line contains integers in the range indicating the color of each cell in Picowso's latest 1-dimensional painting.
출력
Output the minimum number of brush strokes needed to copy the painting.
예제 입력 1
10
1 2 3 4 1 4 3 2 1 6
예제 출력 1
6
점수
In test cases 2-4, only colors and appear in the painting.In test cases 5-10, the color of the -th cell is in the range for each .Test cases 11-20 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인