PAIRDIFF


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 493M

Problem type

Cho dãy số nguyên \(a[1],a[2],…,a[n]\). Hãy tìm tất cả các cặp \((a[i],a[j])\) sao cho \(|a[i] – a[j]|\) đạt giá trị nhỏ nhất.

Dữ liệu vào:

  • Dòng đầu chứa số nguyên dương \(n (2 ≤n ≤200000)\);

  • Dòng tiếp theo chứa \(n\) số nguyên \(a[1],a[2],…,a[n](-10^7≤a[i]≤10^7,a[i]≠a[j])\)

Dữ liệu ra:

  • Ghi ra các cặp số \((a[i]≠a[j])\) thỏa đề theo thứ tự tăng dần.

Sample Input

10
-20 -3916237 -357920 -3620601 7374819 -7330761 30 6246457 -6461594 266854

Sample Output

-20 30

Sample Input

12
-20 -3916237 -357920 -3620601 7374819 -7330761 30 6246457 -6461594 266854 -520 -470

Sample Output

-520 -470 -20 30

Sample Input

4
5 4 3 2

Sample Output

2 3 3 4 4 5

Comments

There are no comments at the moment.