Binary Search on AnswerGreedy
There are n stalls at given positions along a line and c cows to place in them, one cow per stall. Place the cows so that the smallest distance between any two cows is as large as possible, and print that distance.
Input
Line 1: n and c. Line 2: n stall positions (not necessarily sorted).
Output
Print the largest possible minimum distance between two cows.
Constraints
2 <= c <= n <= 200 0 <= position <= 10^4 All positions are distinct.
Example 1
Input
5 3 1 2 8 4 9
Output
3
Place cows at 1, 4 and 9: the smallest gap is 3.