QOJ.ac

QOJ

Límite de tiempo: 5 s Límite de memoria: 256 MB Puntuación total: 100

#8430. 三台服务器

Estadísticas

有三台相同的服务器和 $n$ 个需要处理的请求。已知处理每个请求所需的时间:在任何一台服务器上处理第 $i$ 个请求都需要 $t_i$ 秒。

你需要以最公平的方式将请求分配给服务器。对于每台服务器,计算其负载:即分配给该服务器的所有请求所需的总时间。如果三台服务器的最大负载与最小负载之差尽可能小,则称该分配方式最公平。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 400$),表示请求的数量。第二行包含整数序列 $t_1, t_2, \dots, t_n$ ($1 \le t_i \le 30$),其中 $t_i$ 是处理第 $i$ 个请求所需的时间。

输出格式

输出四行。第一行必须包含服务器最大负载与最小负载之间可能达到的最小差值。接下来的三行,每行包含分配给一台服务器的请求描述。描述必须以分配的请求数量开头,随后是这些请求的索引(顺序不限)。

如果存在多种可能的答案,输出其中任意一种即可。

样例

输入 1

6
7 3 20 1 5 7

输出 1

9
1 3
3 2 4 1
2 5 6

输入 2

3
7 7 7

输出 2

0
1 3
1 2
1 1

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.