No.716 Distance
タグ : / 解いたユーザー数 533
作問者 :
butsurizuki
/ テスター :
Problem Statement
There are $N$ points on a line $l$.
Their positions are $a_1,a_2…a_N$ (integers).
Find the minimum and maximum values of the distance between any two points.
In the figure, $a_n$ is an error for $a_N$. (Added 2022/08/09)
Input
$N$ $a_1$ $a_2$ $a_3$ $\dots$ $a_N$
The input consists of two lines. The first line gives the number of points $N$, and the second line gives the positions $a$.
・Constraints
$2 \le N \le 1000$
$a_i \le a_{i+1}$ ($1 \le i \le N-1$)
$-10^5 \le a_i \le 10^5$ ($1 \le i \le N$)
Output
Print the minimum distance on the first line and the maximum distance on the second line, followed by a newline at the end.
Sample
Sample 1
Input
4 -1 0 2 3
Output
1 4
Sample 2
Input
3 -1 1 1
Output
0 2
There may be multiple points at the same position, in which case their distance is 0.
Sample 3
Input
2 -100000 100000
Output
200000 200000
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。