#P7391. 「TOCO Round 1」自适应 PVZ

「TOCO Round 1」自适应 PVZ

Description

The unlucky QwQcOrZ\color{black}\texttt Q\color{red}\texttt{wQcOrZ} encountered nn zombies on the lawn. Zombie ii appears at time lil_i and will enter the house at time rir_i.

QwQcOrZ\color{black}\texttt Q\color{red}\texttt{wQcOrZ} has mm Peashooters. If a Peashooter keeps attacking zombie ii continuously during the time interval from lil_i to rir_i (excluding both endpoints), then it can kill zombie ii. However, during the attack it cannot attack any other zombie, and the target zombie cannot be changed.

Now QwQcOrZ\color{black}\texttt Q\color{red}\texttt{wQcOrZ} wants to know: with a proper schedule, what is the minimum number of zombies that will enter his house.

Input Format

The first line contains two integers n,mn, m, representing the number of zombies and the number of Peashooters.

The next nn lines each contain two integers lil_i and rir_i, representing the time when zombie ii appears and the time when it enters the house.

Output Format

Output one integer representing the answer.

2 1
1 2
3 4
0
3 2
1 3
1 3
2 4
1
2 1
1 3
3 5
0

Hint

For 30%30\% of the testdata, n,m6n, m \leq 6.
For 60%60\% of the testdata, n,m103n, m \leq 10^3.
For another 20%20\% of the testdata, mnm \geq n.
For 100%100\% of the testdata, 1n,m2×1051 \leq n, m \leq 2 \times 10^5, 1li<ri1091 \leq l_i < r_i \leq 10^9.

Translated by ChatGPT 5