QOJ.ac

QOJ

Time Limit: 10 s Memory Limit: 1024 MB Total points: 100

#3104. 分配工作站

Statistics

Penelope 是新建超级计算机管理团队的一员。她的工作是为前来使用超级计算机进行计算的研究人员分配工作站。

图片由 NASA 提供,来自维基共享资源

Penelope 非常懒,讨厌为到来的研究人员解锁机器。她可以从办公桌远程解锁机器,但她觉得这种琐碎的任务配不上她的资历。如果她决定无视安全准则,她可以简单地要求研究人员在离开时不要锁定工作站,然后将那些不再使用但仍处于解锁状态的工作站分配给新的研究人员。这样,她只需要为第一个使用该工作站的研究人员解锁一次即可,这对 Penelope 来说是一个巨大的改进。

不幸的是,如果闲置工作站超过 $m$ 分钟,它们会自动锁定。在工作站自动锁定后,Penelope 必须为下一个使用它的研究人员再次解锁。给定研究人员到达和离开的精确时间表,你能告诉 Penelope,通过要求研究人员在离开时不锁定工作站并以最优方式分配新到的研究人员,她最多可以节省多少次解锁操作吗?你可以假设总是有足够的工作站可用。

输入格式

输入包含: 一行,包含两个整数 $n$ ($1 \le n \le 300\,000$),研究人员的数量,以及 $m$ ($1 \le m \le 10^8$),工作站自动锁定的闲置分钟数; $n$ 行,每行包含两个整数 $a$ 和 $s$ ($1 \le a, s \le 10^8$),表示一名研究人员在 $a$ 分钟后到达,并停留恰好 $s$ 分钟。

输出格式

输出 Penelope 最多可以节省的解锁次数。

样例

输入格式 1

3 5
1 5
6 3
14 6

输出格式 1

2

输入格式 2

5 10
2 6
1 2
17 7
3 9
15 6

输出格式 2

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.