luogu#P6397. [COI 2008] GLASNICI

[COI 2008] GLASNICI

Problem Description

There are nn messengers on a straight line. Number them from 11 to nn in order from left to right. In other words, let the coordinate of messenger ii be did_i. Then for 1i<n1 \leq i \lt n, we have didi+1d_i \leq d_{i + 1}.

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 11 unit length per second.
  • When the distance between two messengers is no more than a given real number kk, 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 11 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 kk within which message passing is possible.

The second line contains an integer, the number of messengers nn.

Lines 33 to (n+2)(n + 2) each contain a real number. The real number on line (i+2)(i + 2) is did_i, the coordinate of messenger ii.

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 10310^{-3}, 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 1.51.5 seconds, messenger 11 walks to the right, and messenger 22 walks to the left.

At time 1.51.5 seconds, messenger 11 is at coordinate 1.51.5, and messenger 22 is at coordinate 4.54.5. The distance between them is no more than 33, so they can pass the message.

Constraints and Notes

For all test points, it is guaranteed that:

  • 1n1051 \leq n \leq 10^5, 0k1060 \leq k \leq 10^6.
  • 0di1090 \leq d_i \leq 10^9, and for any 1i<n1 \leq i \lt n, we have didi+1d_i \leq d_{i + 1}.
  • In the input, each real number has exactly 33 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