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

24674번 - Box Packing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB50222262.857%

문제

An ordered pair of integers $(x, y)$ is called a box. A sequence of boxes $(c_1, d_1), \ (c_2, d_2), \ \ldots, \ (c_m, d_m)$ is called a chain if the following inequalities hold: $$ c_1 \le c_2 \le \ldots \le c_m , \quad d_1 \le d_2 \le \ldots \le d_m \text{.} $$

You are given $n$ boxes: $(a_1, b_1), \ (a_2, b_2), \ \ldots, \ (a_n, b_n)$. Find the maximum number of boxes that you can select from them and split into no more than $k$ chains. You can reorder the boxes to form chains.

입력

The first line contains two integers, $n$ and $k$ (1ドル \le n \le 10^5,ドル 1ドル \le k \le 100$).

The $i$-th of the following $n$ lines contains two integers, $a_i$ and $b_i$ (1ドル \le a_i, \ b_i \le 10^9$).

출력

Print one integer: the answer.

제한

예제 입력 1

4 1
2 2
4 2
3 4
5 5

예제 출력 1

3

예제 입력 2

4 2
2 2
4 2
3 4
5 5

예제 출력 2

4

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2022 > Day 3: Kazakhstan Contest I번

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

출처

대학교 대회

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

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