SalesforceOA #34
Minimum Difference
估计简单可在线判题
考点(AI 标注)原地数组
The array elements are distinct. Output all value pairs whose absolute difference is minimal. In each pair the smaller value comes first, and pairs are sorted ascending by the first item and then by the second. The output of the original example [-1,3,6,-5,0] is wrong: the minimum difference is 1, and the only correct value pair is −1 and 0, not the two pairs with difference 3.
输入格式
The input gives n and n distinct integers. The original has no numeric bounds; this site adds 2≤n≤100000, −10^9≤a[i]≤10^9.
输出格式
Output one pair of values with the minimum absolute difference per line, covering all optimal pairs; do not output the number of pairs or the difference.
样例 1
输入:
5
-1 3 6 -5 0
输出:
-1 0
样例 2
输入:
4
4 2 1 3
输出:
1 2
2 3
3 4
样例 3
输入:
2
-7 9
输出:
-7 9
样例说明
The outputs of the three public examples are, in order: -1 0; 1 2 / 2 3 / 3 4; -7 9. They have been checked by independent enumeration or direct simulation.