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

30857번 - Lucky Draws 다국어

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

문제

The ICPC committee is planning a surprise event to cheer on the participating teams. The committee provides each team with a pair of two numbers, $A$ and $B$ ($A ≤ B$), before the competition, which will be used for the lucky draws after the competition. The committee wants to hold $K$ draws. In each draw, a single number $C$ is chosen by the committee, and all teams with a pair $(A, B)$ such that $A ≤ C ≤ B$ win in this draw. To make more teams happy, the committee wants to choose the $K$ numbers used in the $K$ draws in advance so that the most teams win. A team can win multiple times but is considered to have won once.

For example, five teams are participating in ICPC and their pairs are $(1, 2),ドル $(1, 4),ドル $(3, 6),ドル $(4, 7),ドル $(5, 6),ドル and $K = 2$. When the committee chooses two numbers 2ドル$ and 4ドル,ドル four teams with $(1, 2),ドル $(1, 4),ドル $(3, 6)$ and $(4, 7)$ win. The team with $(1, 4)$ wins twice because the pair contains both chosen numbers. In fact, all five teams can win if 2ドル$ and 5ドル$ are chosen. The maximum number of winning teams is five.

Given $n$ pairs of two integers for teams and the number of lucky draws $K,ドル write a program to output the maximum number of winning teams.

입력

Your program is to read from standard input. The input starts with a line containing two integers, $n$ and $K$ (1ドル ≤ n ≤ 10,000円,ドル 1ドル ≤ K ≤ n,ドル 1ドル ≤ n \times K ≤ 500,000円$), where $n$ is the number of teams and $K$ is the number of lucky draws. Each of the following $n$ lines contains two integers $A$ and $B$ that represent the pair of a team, where $-10^6 ≤ A ≤ B ≤ 10^6$.

출력

Your program is to write to standard output. Print exactly one line. The line should contain the maximum number of winning teams. Teams that win more than once should only be counted once.

제한

예제 입력 1

5 2
1 2
1 4
3 6
4 7
5 6

예제 출력 1

5

예제 입력 2

3 2
2 4
1 3
3 5

예제 출력 2

3

예제 입력 3

4 1
2 3
1 1
4 5
4 5

예제 출력 3

2

예제 입력 4

7 2
5 6
7 9
7 7
1 4
2 3
4 7
4 7

예제 출력 4

6

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Asia Regional - Seoul 2023 F번

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 6: K-ontest A번

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

출처

대학교 대회

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

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