luogu#P6397. [COI 2008] GLASNICI
[COI 2008] GLASNICI
Problem Description
There are messengers on a straight line. Number them from to in order from left to right. In other words, let the coordinate of messenger be . Then for , we have .
Messengers pass a message in the following way:
- At any moment (not necessarily an integer time), any messenger (whether they already know the message or not) may freely choose to move left, move right, or stay still. Their speed is unit length per second.
- When the distance between two messengers is no more than a given real number , they can pass the message. That is, if at least one of them knows the message, then both of them will know it. Message passing happens instantly and takes no time.
Now messenger has obtained a message. Find the minimum time needed to make all messengers obtain the message.
Input Format
The first line contains a real number, the maximum distance within which message passing is possible.
The second line contains an integer, the number of messengers .
Lines to each contain a real number. The real number on line is , the coordinate of messenger .
Output Format
This problem uses Special Judge.
Output one real number in one line, the answer. If your output differs from the standard answer by at most , you can get the score for the corresponding test point. Therefore, it is recommended that you keep at least four digits after the decimal point.
3.000
2
0.000
6.000
1.500
2.000
4
0.000
4.000
4.000
8.000
1.000
Hint
Sample 1 Explanation
In the first seconds, messenger walks to the right, and messenger walks to the left.
At time seconds, messenger is at coordinate , and messenger is at coordinate . The distance between them is no more than , so they can pass the message.
Constraints and Notes
For all test points, it is guaranteed that:
- , .
- , and for any , we have .
- In the input, each real number has exactly digits after the decimal point.
Note
This problem is translated from COCI2007-2008 COI2008 T1 GLASNICI. The translation and SPJ are provided by 一扶苏一.
Translated by ChatGPT 5