#K12171. Maximum Distance and Count on a Number Line
Maximum Distance and Count on a Number Line
Maximum Distance and Count on a Number Line
You are given n points on a number line. Your task is to find the largest distance between any two points and the number of pairs that achieve this maximum distance. Note that even if the extreme values appear more than once, they are considered as a single pair.
In other words, if min is the smallest point and max is the largest point, then the maximum distance is computed as \[ \text{maximum distance} = \max - \min \] and the answer for the number of pairs is always 1 if there are at least two points.
If there are fewer than two points, output 0 0
.
inputFormat
The input is read from stdin. It consists of two lines. The first line contains one integer n
(the number of points). The second line contains n
space-separated integers representing the points on a number line.
outputFormat
Print two space-separated integers on stdout: the maximum distance between any two points and the number of pairs achieving this maximum distance. If there are fewer than two points, output 0 0
.
2
1 10
9 1
</p>