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

31514번 - Range Editing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 (추가 시간 없음) 2048 MB53242142.857%

문제

You are editing a list of spreadsheet cells. Initially all cells are empty. You can perform two types of operations:

  1. Select a consecutive range of cells and change their values to a positive integer of your choice. All these cells get the same value after this operation.
  2. Select a consecutive range of cells and delete their values. All these cells become empty after this operation.

Given the final cell values that you would like to have in the spreadsheet, calculate the minimum number of editing operations required to obtain those values.

입력

The first line of input contains a single integer $n$ (1ドル \leq n \leq 800$), which is the number of cells you are editing. The cells are number from 1ドル$ to $n$.

Each of the next $n$ lines contains a single integer between 0ドル$ and 10ドル^9$ inclusive. The integer on the $i^{\text{th}}$ line is 0ドル$ if cell $i$ should be empty after all operations. Otherwise, it is a positive integer that is the final value of cell $i$.

출력

Output a single integer, which the minimum number of editing operations required.

제한

예제 입력 1

10
0
1
2
3
4
2
1
0
0
1

예제 출력 1

5

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 1 I번

ICPC > Regionals > North America > Mid-Central Regional > 2023 Mid-Central USA Programming Contest B번

ICPC > Regionals > North America > South Central USA Regional > 2023 South Central USA Regional Contest > Division 1 H번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2023 Mid-Atlantic USA Regional Contest > Division 1 H번

ICPC > Regionals > North America > Southeast USA Regional > 2023 Southeast USA Regional Programming Contest > Division 1 H번

  • 문제를 만든 사람: Bowen Yu
(追記) (追記ここまで)

출처

대학교 대회

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

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