2195. Tournament

单点时限: 2.0 sec

内存限制: 256 MB

Every September, the Kingdom of Loowater holds a jousting tournament. In each of a series of event, a pair of knights attempt to knock each other from their respective horses. The winning knight is paired with another, while the loser is elimnated. This process continues until all but one knight is eliminated; this knight is declared champion.

The tournament schedule is organized so that no knight needs to compete in more than $e$ events to be champion, for the minimum possible $e$ given $k$, the number of knights. In order to construct the schedule, it may be necessary to identify several knights who compete in fewer than e events; these knights are said to be awarded a bye and are excluded from the first round of competition.

The first round of competition involves pairing as many knights as possible among those who are not awarded a bye. The competition is more interesting if the knights in each pair are as evenly matched in ability as possible. You are to determine which knights should be awarded a bye so as to make the first round as interesting as possible.

输入格式

Standard input consists of several test cases followed by a line containing $0$. Each test case begins with an integer $1 < k \le 2500$, the number of knights. $k$ lines follow, each giving the name and ability of a knight. The name is a string of lower case letters not longer than $20$; the ability is a real number.

The mismatch between knights with abilities $a$ and $b$ respectively is defined to be $(a - b)^2$.

输出格式

For each test case, output the names of the knights to be given a bye such that the sum of all mismatch values for pairs of knights competing in the first round is minimized. If there are several solutions, any will do. Output an empty line between test cases.

样例

Input
3
gallahad 10
lancelot 11
mccartney 2
0
Output
mccartney

1 人解决,3 人已尝试。

1 份提交通过,共有 4 份提交。

9.9 EMB 奖励。

创建: 15 年,8 月前.

修改: 6 年,3 月前.

最后提交: 2 年,1 月前.

来源: Waterloo Local Contest, 2007.9.29

题目标签