QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#5382. 灾难性的停机时间

统计

你正在调查最近一次计算机系统崩溃的原因。到目前为止,你得出的结论是系统过载了;看起来它无法处理海量涌入的请求。自那次事故以来,你有充足的机会为系统增加更多的服务器,从而使其能够处理更多的并发请求。然而,你一直太懒而没有去做——直到现在。事实上,你很快就会添加所有必要的服务器!

Claus Rebler, cc-by-sa

为了预测未来对系统的请求,你联系了服务的客户,询问他们近期将如何使用该服务。反馈非常令人印象深刻;客户为你发送了他们将要发出的每一个请求的精确时间戳列表!

你已经整理了一份包含 $n$ 个即将到来的请求的列表,时间以毫秒为单位。每当一个请求到来时,它会立即被发送到你的一台服务器上。一个请求需要正好 $1000$ 毫秒来处理,并且必须立即开始处理。

每台服务器最多可以同时处理 $k$ 个请求。给定这一限制,你能计算出为防止系统再次崩溃所需的最少服务器数量吗?

输入格式

第一行包含两个整数 $1 \le n \le 100\,000$ 和 $1 \le k \le 100\,000$,分别表示即将到来的请求数量和每台服务器每秒最多能处理的请求数。

接下来 $n$ 行,每行包含一个整数 $0 \le t_i \le 100\,000$,表示第 $i$ 个请求将在你通知客户后的 $t_i$ 毫秒发生。时间戳按时间顺序排列。多个请求可能在同一时间到达。

输出格式

输出一行,包含一个整数:为处理所有传入请求且不导致系统再次崩溃所需的最少服务器数量。

样例

输入格式 1

2 1
0
1000

输出格式 1

1

输入格式 2

3 2
1000
1010
1999

输出格式 2

2

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.