[LeetCode] Minimize Max Distance to Gas Station 最小化去加油站的最大距离

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Minimize Max Distance to Gas Station 最小化去加油站的最大距离相关的知识,希望对你有一定的参考价值。

 

On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length.

Now, we add K more gas stations so that D, the maximum distance between adjacent gas stations, is minimized.

Return the smallest possible value of D.

Example:

Input: stations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], K = 9
Output: 0.500000

Note:

  1. stations.length will be an integer in range [10, 2000].
  2. stations[i] will be an integer in range [0, 10^8].
  3. K will be an integer in range [1, 10^6].
  4. Answers within 10^-6 of the true value will be accepted as correct.

 

s

 

以上是关于[LeetCode] Minimize Max Distance to Gas Station 最小化去加油站的最大距离的主要内容,如果未能解决你的问题,请参考以下文章

minimize max gas station

[LeetCode] 1675. Minimize Deviation in Array

[LeetCode] 1877. Minimize Maximum Pair Sum in Array

[LeetCode] 928. Minimize Malware Spread II 最大程度上减少恶意软件的传播之二

Leetcode 1877. Minimize Maximum Pair Sum in Array

带有两个方程的 scipy.minimize 仅返回初始值