#P15784. [JAG 2025 Summer Camp #3] Fireworks

[JAG 2025 Summer Camp #3] Fireworks

题目描述

There are NN apartment buildings equally spaced along a straight line. Building ii (1iN1 \leq i \leq N) is located at coordinate i×Li \times L and has height HiH_i.

This year, a fireworks festival will be held, and the residents of each building want to watch the fireworks from its rooftop. However, depending on the launch position, their view may be blocked by other buildings. To avoid this, for each given launch coordinate XjX_j, determine the minimum height such that all residents can see the fireworks.

More formally, find the minimum non-negative real number hjh_j such that there do not exist indices a,ba, b (1a,bN1 \leq a, b \leq N) for which the line segment connecting (a×L,Ha)(a \times L, H_a) and (Xj,hj)(X_j, h_j) (excluding endpoints) intersects with the line segment connecting (b×L,0)(b \times L, 0) and (b×L,Hb)(b \times L, H_b) (excluding endpoints).

输入格式

The input consists of a single test case in the following format.

$$\begin{aligned} & N \ L \ Q \\ & H_{1} \ H_{2} \ \ldots \ H_{N} \\ & X_{1} \\ & \vdots \\ & X_{Q} \end{aligned}$$

The first line contains integers NN (1N3000001 \leq N \leq 300\,000), LL (1L10001 \leq L \leq 1\,000), and QQ (1Q3000001 \leq Q \leq 300\,000), representing the number of apartment buildings, the distance between adjacent buildings, and the number of candidate launch coordinates, respectively.

The next line contains NN integers HiH_i (1Hi1091 \leq H_i \leq 10^9), representing the height of building ii.

Each of the following QQ lines contains an integer XjX_j (109Xj109-10^9 \leq X_j \leq 10^9, Xji×LX_j \neq i \times L for i=1,,Ni = 1, \ldots, N), representing a candidate coordinate for launching the fireworks.

输出格式

For the QQ queries, output the answers separated by newlines. On the jj-th line, output the minimum launch height required when the fireworks are launched at coordinate XjX_j. The answer will be considered correct if the absolute or relative error is less than 10610^{-6}.

3 7 3
5 9 13
10
-9
28
6.7142857143
0
17