QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 32 MB Total points: 100

#14464. 作业调度

Statistics

国际中央工程组织(CEOI)收到了未来 $N$ 天内的 $M$ 个任务请求。完成一个任务需要一台机器工作整整一天。CEOI 可以使用多台机器,每台机器每天最多只能执行一个任务。因此,该组织每天最多能完成的任务数量等于可用机器的数量。CEOI 的目标是使任务的延迟不超过 $D$ 天,这意味着如果客户在第 $S$ 天提交了一个任务进行处理,那么它必须在不晚于第 $S+D$ 天完成。

任务

编写一个程序,计算该组织在保证所有任务延迟不超过 $D$ 天的前提下,所需的最少机器数量。

输入格式

第一行包含三个整数:$N$($1 \le N \le 100\,000$)表示该组织执行任务的总天数,$D$($0 \le D < N$)表示允许的最大延迟天数,$M$($1 \le M \le 1\,000\,000$)表示任务请求的数量。天数从 $1$ 到 $N$ 编号,任务请求从 $1$ 到 $M$ 编号。

第二行包含恰好 $M$ 个由空格隔开的整数,第 $i$ 个数字表示第 $i$ 个请求被提交处理的天数。在第 $N-D$ 天之后不会有任何任务被提交。

输出格式

第一行包含一个整数,表示该组织在保证所有任务延迟不超过 $D$ 天的前提下,所需的最少机器数量。

接下来的 $N$ 行描述一个可行的任务调度方案。第 $i+1$ 行包含安排在第 $i$ 天执行的任务请求的编号。每行中的数字必须用空格隔开,并以 0 结尾。

如果有多个解,你的程序只需输出其中任意一个即可。

样例

输入格式 1

8 2 12
1 2 4 2 1 3 5 6 2 3 6 4

输出格式 1

2
5 1 0
9 4 0
2 10 0
6 12 0
3 7 0
11 8 0
0
0

子任务

  • 在 50% 的测试用例中,$M$ 最多为 $100\,000$。
  • 如果只有第一行(最少机器数)正确,将获得 40% 的分数。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.