| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 291 | 85 | 69 | 28.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.
5 2 1 2 1 4 3 6 4 7 5 6
5
3 2 2 4 1 3 3 5
3
4 1 2 3 1 1 4 5 4 5
2
7 2 5 6 7 9 7 7 1 4 2 3 4 7 4 7
6
ICPC > Regionals > Asia Pacific > Korea > Asia Regional - Seoul 2023 F번
Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 6: K-ontest A번