cswork / OA打开练习工作台

IBMOA #56

Minimum Difference

估计简单可在线判题

考点(AI 标注)原地数组

Given distinct integers, find all unordered pairs with the minimum absolute difference. In each pair the smaller number comes first, and all pairs are output in ascending order by the first item, then by the second.

输入格式

The first line contains n, and the second line contains distinct integers. 2≤n≤100000, −10^9≤value≤10^9.

输出格式

Output the number of pairs on the first line, followed by two integers per line in the specified order.

样例 1

输入:

5
-1 3 6 -5 0

输出:

1
-1 0

样例 2

输入:

5
6 5 4 3 7

输出:

4
3 4
4 5
5 6
6 7

样例 3

输入:

4
1 3 5 10

输出:

2
1 3
3 5

样例说明

The examples give only -1 0; 3 4, 4 5, 5 6, 6 7; and 1 3, 3 5 respectively. The wrong answer in the original site's first example has been corrected according to the statement body.