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

19113번 - Master Zhu and Chessboard 다국어

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

문제

Master Zhu has a rectangular board consisting of $N$ rows and $M$ columns. In the $i$-th row, the squares from the column $L_i$ to the column $R_i$ inclusive are colored black, and all other squares are colored white. Additionally, it is known that $L_i \le L_{i + 1}$ and $R_i \le R_{i + 1}$. Now Master Zhu is going to place some chess pieces on several black squares so that for each black square, there is at least one chess piece in its row or in its column.

Find the minimum number of chess pieces he should place.

입력

The first line of the input contains two integers $N$ and $M$: the number of rows and columns $(1 \le N, M \le 100)$. Each of the next $N$ lines contains two integers $L_i$ and $R_i$ (1ドル \le L_i \le R_i \le M$). It is guaranteed that $L_i \le L_{i + 1}$ and $R_i \le R_{i + 1}$.

출력

Output the minimum number of chess pieces Master Zhu should place.

제한

예제 입력 1

3 3
1 1
2 2
3 3

예제 출력 1

3

예제 입력 2

2 4
1 3
2 4

예제 출력 2

2

예제 입력 3

3 2
1 2
1 2
1 2

예제 출력 3

2

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 8: UESTC Selection B번

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

출처

대학교 대회

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

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