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

32999번 - Ribbon on the Christmas Present 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB102766777.907%

문제

You are preparing a ribbon to decorate the Christmas present box. You plan to dye the ribbon, initially white, to make a stripe pattern of different shades of red. The ribbon consists of a number of sections, each of which should be dyed as planned.

You want to prepare the ribbon with the least number of dyeing steps. Contiguous sections of the ribbon can be dyed in one step with the same shade of red. A ribbon section already dyed with some shade of red can be overdyed with dyestuff of a darker shade; it is colored with that darker shade. Overdyeing with a lighter shade is, however, not allowed. As the ribbon is initially white, all the sections must be dyed at least once.

Figure A.1. Stripe Pattern of Sample Input 1

Figure A.1 shows the pattern of Sample Input 1. The ribbon has six sections and the numbers in the sections mean the levels of shades to be dyed. Larger numbers mean darker shades. This can be made by three dyeing steps:

  1. dye the entire ribbon with red dyestuff of shade level 50ドル,ドル
  2. dye the second section from the left with darker shade dyestuff of level 100ドル,ドル and then 3.
  3. dye the fifth section with dyestuff of level 100ドル$.

Write a program that computes the least number of dyeing steps to make the planned stripe pattern.

입력

The input consists of a single test case of the following format.

$n$

$d_1$ $d_2$ $\cdots$ $d_n$

The test case starts with an integer $n$ (1ドル ≤ n ≤ 100$), the number of sections of the ribbon. The second line contains $n$ integers, $d_1, d_2, \dots , d_n,ドル describing the planned shade levels of the $n$ sections. Here, $d_i$ means the planned shade level of the $i$-th section, which is between 1ドル$ and 100ドル,ドル inclusive, larger meaning darker.

출력

Output a line containing the least number of dyeing steps to make the planned stripe pattern.

제한

예제 입력 1

6
50 100 50 50 100 50

예제 출력 1

3

예제 입력 2

5
1 2 3 2 1

예제 출력 2

3

예제 입력 3

5
3 2 1 2 3

예제 출력 3

5

예제 입력 4

10
1 20 100 1 20 20 100 100 20 20

예제 출력 4

5

예제 입력 5

5
10 60 100 30 10

예제 출력 5

4

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > 2024 ICPC Asia Yokohama Regional Contest A번

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

출처

대학교 대회

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

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