当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7170:Package Delivery

题目描述
Little Q likes online shopping very much. In the next $10^9$ days, there will be $n$ packages delivered to the post office in total. Let's label the next $10^9$ days as day 1, day 2, $\dots$, day $10^9$ respectively. For the $i$-th package, it will arrive at the post office at day $l_i$, and the deadline to take it back home is day $r_i$, which means Little Q can take it back home at day $x$ if and only if $l_i\leq x\leq r_i$.

Every time Little Q comes to the post office, he can take at most $k$ packages together back home at the same time. Note that Little Q can go to the post office multiple times during a single day. Please help Little Q determine how to take these $n$ packages back home such that the number of times he will go to the post office is minimized.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 3\,000$), the number of test cases. For each test case:

The first line contains two integers $n$ and $k$ ($1 \leq k\leq n \leq 100\,000$), denoting the number of packages and the number of packages Little Q can carry at the same time.

Each of the following $n$ lines contains two integers $l_i$ and $r_i$ ($1 \leq l_i\leq r_i \leq 10^9$), describing a package.

It is guaranteed that the sum of all $n$ is at most $1\,000\,000$.
输出解释
For each test case, output a single line containing an integer, denoting the minimum possible number of times that Little Q will go to the post office.
输入样例
1
4 2
1 3
2 4
6 7
4 7
输出样例
2

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7170

最后修改于 2022-09-15T06:17:09+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/2000MS(Java/Others) 524288/524288K(Java/Others)