Problem Z
Tournament

The tournament schedule is organized so that no knight needs
to compete in more than
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.
Input
Standard input consists of several test cases (at most
The mismatch between knights with abilities
Output
For each test case, output the number of knights to be given a bye, followed by their names. The knights to be given a bye should be chosen such that the sum of all mismatch values for pairs of knights competing in the first round is minimized (assuming these are paired up in an optimal way). If there are several solutions, any will do.
Sample Input 1 | Sample Output 1 |
---|---|
3 gallahad 10 lancelot 11 mccartney 2 4 gallahad 10 lancelot 11 mccartney 2 brienne 40 0 |
1 mccartney 0 |