There are n candidate positions for fuel stations along a highway, given as
integer coordinates (not necessarily sorted, not necessarily distinct... they
are distinct in this problem). You must build exactly k of them. To keep the
network robust, you want to maximize the minimum distance between any two
built stations.
Line 1: two integers n k (2 ≤ k ≤ n ≤ 10^5)
Line 2: n integers, the candidate positions (0 ≤ x_i ≤ 10^9, all distinct)
A single integer: the largest possible value of the minimum pairwise distance
between the k chosen stations.
Input:
5 3
1 2 8 4 9
Output:
3
Case 1
5 3 1 2 8 4 9
3
Case 2
4 2 1 1000000000 500000000 250000000
999999999
Input
5 3 1 2 8 4 9
Expected Output
3
Run or submit your code to see output here.