#BS0000391. Khoảng cách trạm xăng nhỏ nhất (Minimize Max Distance to Gas Station)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Khoảng cách trạm xăng nhỏ nhất (Minimize Max Distance to Gas Station)
Minimize Max Distance to Gas Station
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are gas stations at distinct integer coordinates on a line. Add exactly stations at arbitrary real coordinates. Minimize the largest distance between consecutive stations after the additions.
Input
The first line contains integers , the current and additional station counts. The second line contains the strictly increasing integers .
Output
Print the minimum possible value. Absolute error must not exceed .
Subtasks
- Subtask 1 (20 points): ; ; for all ; for all .
- Subtask 2 (30 points): ; ; for all ; for all .
- Subtask 3 (50 points): ; ; for all ; for all .
Examples
Input
10 9
1 2 3 4 5 6 7 8 9 10
Output
0.500000000000
Explanation
Place one station at the midpoint of each of the nine unit gaps. Every new gap is 0.5. A smaller maximum requires at least two new stations per original gap, or 18 in total.
Input
10 1
23 24 36 39 46 56 57 65 84 98
Output
14.000000000000
Explanation
The initial gaps of lengths 19 and 14 lie between 65 and 84, and between 84 and 98, respectively. Place the new station at 74.5, dividing the 19-unit gap into two gaps of length 9.5. All remaining gaps are at most 14. A maximum below 14 would require splitting both of the original gaps, which cannot be done with one station.