1676. 跳石头
1676. 跳石头
中文English
There are n
stones between the starting point and the end point. The distance between the starting point and the ith
(i starts from 0) stone is d[i]
. And the distance between the starting point and end point is target
. From the starting point, we can only jump to the adjacent stone until the end point.
Now you can remove at most m
stones. Return the the shortest jump distance** from the starting point to the end point** in each case, , what is the maximum value of the shortest distance values of all moving stones?
样例
样例 1:
输入: n = 5, m = 2, target = 25, d = [2,11,14,17,21]
输出: 4
解释: 移走第一个和第三个石头, 然后跳跃的路径就是:
1. 0 -> 11 11
2. 11 -> 17 6
3. 17 -> 21 4
4. 21 -> 25 4
样例 2:
输入: n = 0, m = 0, target = 10, d = []
输出: 10
解释: 起点和终点直接没有石头, 也不需要移走任何石头. 直接从起点跳到终点, 距离为 10.
注意事项
- 0 \leq m \leq n \leq 50,0000≤m≤n≤50,000
- 1 \leq target \leq 1,000,000,0001≤target≤1,000,000,000
- 这些石头按与起点距离从小到大的顺序给出, 且不会有两个岩石出现在同一个位置.