#C10007. Schedule Matches
Schedule Matches
Schedule Matches
You are given multiple datasets where each dataset represents a group of players. Each dataset starts with an integer (N) (which is even and (N \ge 2)) indicating the number of players, followed by a line of (N) space-separated integers that denote the players' skill ratings. Your task is to form matches between players such that the difference in skill ratings in each match is minimized. To accomplish this, sort the skill ratings and then pair adjacent players. The output for each dataset should list the pairs in the format ((a, b)) separated by a comma and a space, with each dataset's result printed on a new line.
inputFormat
Input is read from standard input (stdin). The input contains one or more datasets. For each dataset, the first line contains an integer (N) (even and (N \ge 2)) representing the number of players. The next line contains (N) space-separated integers representing the players' skill ratings. A dataset starting with (N = 0) indicates the end of input and should not be processed.
outputFormat
For each dataset, output a single line on standard output (stdout) containing the matched pairs. Each pair must be formatted as ((a, b)) and pairs should be separated by a comma and a space.## sample
6
5 3 2 8 6 9
4
10 1 3 20
0
(2, 3), (5, 6), (8, 9)
(1, 3), (10, 20)
</p>