#P11290. 【MX-S6-T2】「KDOI-11」飞船
【MX-S6-T2】「KDOI-11」飞船
Background
Original link: https://oier.team/problems/S6B.
Problem Description
Xun built a very powerful spaceship. To test her spaceship, Xun built an infinitely long ray starting from the origin as the runway. There are fuel stations on the runway. The -th station is at position from the origin. Xun can spend time here to add fuel of type . Fuel at the same station cannot be added twice. It is guaranteed that and is an integer.
This spaceship is powerful in two aspects:
- Its fuel consumption is extremely low and can be ignored in this problem. That is, we do not consider the case where fuel runs out.
- If fuel of type is added, the spaceship's speed increases from to . Note that the effects of fuels can stack.
Now, Xun gives queries. For each query, Xun sets the destination at position on the runway from the origin. Starting from the origin, the spaceship's speed is set to unit per time. For each fuel station passed, you may freely choose whether to refuel. You need to tell Xun the minimum time needed to reach the destination (i.e., ) for each query.
Input Format
The first line contains two positive integers , representing the number of fuel stations and the number of queries.
The next lines each contain three positive integers , representing the distance of the -th fuel station from the origin, the time required to refuel, and the fuel type. The fuel stations are given in strictly increasing order of , i.e., . It is guaranteed that .
The next line contains positive integers , representing the queries.
Output Format
Output lines, each containing a non-negative real number, representing the answer.
This problem uses a custom checker to verify your output. You only need to ensure that the relative or absolute error between your answer and the standard answer does not exceed . That is, for each query, suppose your answer is and the standard answer is . If $\frac{\lvert x-y\rvert}{\max(1,\lvert y\rvert)}\leq 10^{-6}$, then your answer is considered correct.
4 4
1 1 1
3 1 2
8 5 2
10 100 3
1 4 10 1000
1
4
7.5
194.5
Hint
[Sample Explanation #1]
- For query , do not refuel, and the required time is .
- For query , do not refuel, and the required time is .
- For query , refuel with type at fuel station located units from the origin. The speed increases to , and the required time is .
[Sample #2]
See ship/ship2.in and ship/ship2.ans in the attachment.
This sample satisfies the constraints of test points .
[Sample #3]
See ship/ship3.in and ship/ship3.ans in the attachment.
This sample satisfies the constraints of test points .
[Sample #4]
See ship/ship4.in and ship/ship4.ans in the attachment.
This sample satisfies the constraints of test points .
[Constraints]
For all testdata, it is guaranteed that: , , , , , .
| Test Point ID | ||||
|---|---|---|---|---|
Translated by ChatGPT 5