#C1224. Pair Participants Minimizing Skill Difference
Pair Participants Minimizing Skill Difference
Pair Participants Minimizing Skill Difference
You are given a number \(n\) representing the number of participants and a list of \(n\) integers representing the participants' skill levels in non-decreasing order. Your task is to pair the participants such that the absolute difference between skill levels in each pair is minimized. The pairing is done sequentially: the first two participants form the first pair, the next two the second, and so on. If \(n\) is odd, then the last participant remains unpaired and should be printed alone.
Input Format: The first line contains a single integer \(n\). The second line contains \(n\) space-separated integers denoting the skill levels.
Output Format: For each pair, output a line with the two integers separated by a space. If there is an unpaired participant (when \(n\) is odd), output their skill level on the last line.
Examples:
Input: 6 1 2 3 5 9 12</p>Output: 1 2 3 5 9 12
Input: 5 1 1 3 4 9
Output: 1 1 3 4 9
inputFormat
The input is read from standard input and consists of two lines. The first line contains a single integer \(n\), the number of participants. The second line contains \(n\) space-separated integers representing the participants' skill levels in non-decreasing order.
outputFormat
Print the pairs sequentially, one pair per line. Each line should contain two space-separated integers for a pair. If \(n\) is odd, the last line will contain a single integer representing the unpaired participant.
## sample6
1 2 3 5 9 12
1 2
3 5
9 12
</p>