#P5554. Maximum Basketball Height Query
Maximum Basketball Height Query
Maximum Basketball Height Query
You are given information about multiple basketball throwing events. When a basketball is thrown, its throwing time \(l\), its initial height \(h\), and its upward initial velocity \(v\) are recorded. When the basketball is caught at time \(r\), it is no longer tracked.
For a ball thrown at time \(l\), its height at any time \(x\) (with \(x \ge l\)) is given by the formula:
[ h_x = h + v \times (x - l) - 5(x-l)^2 ]
Given a query time \(x\), determine the maximum height among all basketballs that are in the air at time \(x\), i.e. those satisfying \(l \le x < r\). If there is no basketball in the air at time \(x\), output 0.
Note: The times \(l\), \(r\), and query times \(x\) are provided in no specific order.
inputFormat
The first line contains two integers \(n\) and \(q\) representing the number of basketballs and the number of queries, respectively.
Each of the next \(n\) lines contains four integers \(l\), \(r\), \(h\), \(v\) where \(l\) is the time the ball is thrown, \(r\) is the time the ball is caught, \(h\) is the initial height, and \(v\) is the upward initial velocity.
Each of the next \(q\) lines contains a single integer \(x\), the query time.
outputFormat
For each query, output the maximum height among all basketballs in the air at time \(x\). If no basketball is in the air, output 0.
Each answer must be printed on a new line and rounded to exactly 6 decimal places.
sample
2 3
1 10 5 10
3 8 2 20
2
3
9
10.000000
5.000000
-235.000000
</p>