2302. Pirates On Parade

单点时限: 2.0 sec

内存限制: 256 MB

Davy Jones wants his men to line up on parade. The men are to line up in pairs, from shortest to tallest. However, two pirates in the same pair can only differ in height by at most 2 inches. You start lining up the pirates in pairs in order, starting with the shortest pirate. If after selecting a pirate it is not possible to find a pirate sufficiently near his height (or if there are no pirates left), the unpaired pirate will be forced to walk the plank! You may assume no pirates are exactly the same height.

输入格式

The input will be a list of pirates listed by name and their height in inches as an integer.

输出格式

The output should be the names of pairs of pirates, each on a single line, in order from shortest to tallest. The shorter pirate in each pair should be first. Any pirates forced to walk the plank should not be listed.

样例

Input
Sam 60
Dan 52
Bob 54
Art 61
/*
Sam 60
Dan 52
Bob 54
Kim 70
Art 61
*/
Output
Dan Bob
Sam Art
/*
Dan Bob
Sam Art
*/

45 人解决,54 人已尝试。

51 份提交通过,共有 82 份提交。

3.2 EMB 奖励。

创建: 15 年,8 月前.

修改: 6 年,8 月前.

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

来源: 2007 Maryland High-school Programming Contest

题目标签