Problem H
Height Profile
The cycling classic Amstel Gold Race is held annually in the
nearby Dutch province of Limburg. It features frequent short
climbs giving contestants little time to recover in between.
For instance the last
The incline grade for each climb is given in
percent. An incline grade of
You know the height of the road at integer horizontal
kilometres from the start of the race, and for simplicity we
model the heights as being piecewise-linear in between these
points. In other words, the incline grade is assumed to be
constant between
![\includegraphics[width=0.9\textwidth ]{profile}](/problems/heightprofile/file/statement/en/img-0001.png)
The Amstel Gold Race cannot be compared with some hilly stages of the Tour de France or the Giro d’Italia, but you are still interested in a comparison. For each one-day race, whether it is the Amstel Gold Race or one of the stages of the Tour de France, you would like to know the length of the longest horizontal interval with at least a given incline grade. Actually, you would like to know the answer for multiple incline grades.
The incline grade of a horizontal interval is measured
between the two endpoints. For example, the incline grade
between kilometers
Input
The input consists of:
-
One line with two integers
and ( ), the horizontal length of the race in kilometres and the number of incline grades you have chosen. -
One line with
integers ( ), where is the height of the route in metres horizontal kilometres from the start. -
lines each containing a real number ( and has exactly one digit after the decimal point), an incline grade you care about.
Output
For each of the
Your answers should have an absolute or relative error of at
most
Sample Input 1 | Sample Output 1 |
---|---|
8 2 0 0 10 30 60 45 75 65 30 2.0 3.1 |
3.000000000 impossible |
Sample Input 2 | Sample Output 2 |
---|---|
2 2 0 30 30 3.0 2.0 |
1.000000000 1.500000000 |