Placing routers at positions 1, 4, and 8 keeps every neighboring gap at least 3; a gap of 4 cannot place all three.
Output
3
Input
4 2
10 1 20 30
Explanation
Using positions 1 and 30 gives the largest minimum distance, 29.
Output
29
Input
6 4
0 5 10 15 20 25
Explanation
Four routers can be placed at 0, 5, 15, and 25, so the best minimum distance is 5.
Output
5
There are n house positions on a line. Place k routers in distinct houses so that the minimum distance between any two placed routers is as large as possible.
2≤k≤n≤2⋅105
0≤pi≤109
House positions are distinct, but not necessarily given in order.