IBMOA #50
Maximize Minimum Distance
Estimated MediumJudge-ready
Topics (AI-labelled)Binary SearchGreedy
From n distinct points on the x axis, choose k so that the minimum distance between any two chosen points is as large as possible, and output that maximum value.
Input
The first line contains n k, and the second line contains the coordinates. 2≤n≤100000, 0≤coordinate≤10^9 with all coordinates distinct, 2≤k≤n.
Output
Output one integer, the answer.
Example 1
Input:
5 3
1 4 2 9 8
Output:
3
Example 2
Input:
2 2
0 10
Output:
10
Example 3
Input:
3 3
1 2 3
Output:
1
Example notes
The examples give 3, 10 and 1 respectively.
Editorial
Loading solution…