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

建议使用的浏览器:

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

1607:Station Balance

题目描述
The International Space Station contains many centrifuges in its labs. Each centrifuge will have some number (C) of chambers each of which can contain 0, 1, or 2 specimens. You are to write a program which assigns all S specimens to the chambers such that no chamber contains more than 2 specimens and the following expression for IMBALANCE is minimized.



where:

CMi is the Chamber Mass of chamber i and is computed by summing the masses of the specimens assigned to chamber i.

AM is the Average Mass of the chambers and is computed by dividing the sum of the masses of all specimens by the number of chambers (C).

输入解释
Input to this program will be multiple sets of input. The first line of each set will contain two numbers. The first number (1 <= C <= 5) defines the number of chambers in the centrifuge and the second number (1 <= S <= 2C) defines the number of specimens in the input set. The second line of input will contain S integers representing the masses of the specimens in the set. Each specimen mass will be between 1 and 1000 and will be delimited by the beginning or end of the line and/or one or more blanks.
输出解释
For each input set, you are to print a line specifying the set number (starting with 1) in the format "Set #X" where "X" is the set number.

The next C lines will contain the chamber number in column 1, a colon in column number 2, and then the masses of the specimens your program has assigned to that chamber starting in column 4. The masses in your output should be separated by exactly one blank.

Your program should then print ``IMBALANCE = X" on a line by itself where X is the computed imbalance of your specimen assignments printed to 5 digits of precision to the right of the decimal.

The final line of output for each set should be a blank line. (Follow the sample output format.)

输入样例
2 3
6 3 8
3 5
51 19 27 14 33
5 9
1 2 3 5 7 11 13 17 19
输出样例
Set #1
 0: 6 3
 1: 8
IMBALANCE = 1.00000

Set #2
 0: 51
 1: 19 27
 2: 14 33
IMBALANCE = 6.00000

Set #3
 0: 1 17
 1: 2 13
 2: 3 11
 3: 5 7
 4: 19
IMBALANCE = 11.60000
来自杭电HDUOJ的附加信息
Recommend lcy

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

题目来源 South Central USA 1996

源链接: HDU-1607

最后修改于 2020-10-25T22:46:25+00:00 由爬虫自动更新

共提交 40

通过率 12.5%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/32768K(Java/Others)