#P17006. [NWERC 2019] Height Profile

[NWERC 2019] Height Profile

Problem Description

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 4242 kilometres of the race has 88 steep climbs of average length roughly 11 kilometre each.

The incline grade for each climb is given in percent. An incline grade of 100%100\% means that for every 11 horizontal metre travelled, you also travel 11 vertical metre upwards. An incline grade of 0%0\% is perfectly flat. In general, an incline grade of p%p\% has p/100p / 100 vertical metres for each horizontal metre. Note that the incline grade can also be negative.

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 00 and 11 km, and between 11 and 22 km, and so on. For example, in Figure, the height at the horizontal distance 2.52.5 kilometres is exactly 2020 metres.

:::align{center} :::

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 11 and 44 of the race in Figure is 2%2\%, as 6060 vertical metres are gained in 22 kilometres. This horizontal interval is also the longest one with an incline grade of at least 2%2\%.

Input Format

The input consists of:

  • One line with two integers nn and kk (2n105,1k502\leq n\leq 10^5, 1\leq k\leq 50), the horizontal length of the race in kilometres and the number of incline grades you have chosen.

  • One line with n+1n + 1 integers h0,h1,,hnh_0, h_1, \ldots, h_n (0hi1090\leq h_i\leq 10^9), where hih_i is the height of the route in metres ii horizontal kilometres from the start.

  • kk lines each containing a real number gg (100g100-100 \le g \le 100 and gg has exactly one digit after the decimal point), an incline grade you care about.

Output Format

For each of the kk given incline grades, in the same order as in the input, output the length in kilometres of the longest horizontal interval with at least this incline grade. If no suitable interval exists, output impossible.

Your answers should have an absolute or relative error of at most 10610^{-6}.

8 2
0 0 10 30 60 45 75 65 30
2.0
3.1
3.000000000
impossible
2 2
0 30 30
3.0
2.0
1.000000000
1.500000000