#P11290. 【MX-S6-T2】「KDOI-11」飞船

    ID: 12430 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP贪心Special JudgeO2优化背包 DP梦熊比赛

【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 nn fuel stations on the runway. The ii-th station is at position pip_i from the origin. Xun can spend tit_i time here to add fuel of type xix_i. Fuel at the same station cannot be added twice. It is guaranteed that 1xi4\boldsymbol{1\leq x_i\leq 4} and xi\boldsymbol{x_i} 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 xx is added, the spaceship's speed increases from vv to v×xv\times x. Note that the effects of fuels can stack.

Now, Xun gives qq queries. For each query, Xun sets the destination at position yiy_i on the runway from the origin. Starting from the origin, the spaceship's speed is set to 11 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., yiy_i) for each query.

Input Format

The first line contains two positive integers n,qn, q, representing the number of fuel stations and the number of queries.

The next nn lines each contain three positive integers pi,ti,xip_i, t_i, x_i, representing the distance of the ii-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 pip_i, i.e., pi<pi+1p_i < p_{i + 1}. It is guaranteed that 1xi41\leq x_i\leq 4.

The next line contains qq positive integers y1,,yqy_1, \ldots, y_q, representing the queries.

Output Format

Output qq 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 10610^{-6}. That is, for each query, suppose your answer is xx and the standard answer is yy. 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 y1=1y_1=1, do not refuel, and the required time is 11.
  • For query y2=4y_2=4, do not refuel, and the required time is 44.
  • For query y3=10y_3=10, refuel with type 22 at fuel station 22 located 33 units from the origin. The speed increases to 22, and the required time is 3+1+1032=7.53+1+\frac{10-3}{2}=7.5.

[Sample #2]

See ship/ship2.in and ship/ship2.ans in the attachment.

This sample satisfies the constraints of test points 131\sim 3.

[Sample #3]

See ship/ship3.in and ship/ship3.ans in the attachment.

This sample satisfies the constraints of test points 575\sim 7.

[Sample #4]

See ship/ship4.in and ship/ship4.ans in the attachment.

This sample satisfies the constraints of test points 182018\sim 20.

[Constraints]

For all testdata, it is guaranteed that: 1n1051\leq n\leq 10^5, 1q1051\leq q\leq10^5, 1p1<p2<<pn1091\leq p_1<p_2<\dots<p_n\leq 10^9, 1ti1091\leq t_i\leq10^9, 1xi41\leq x_i\leq4, 1yi1091\leq y_i\leq 10^9.

Test Point ID nn\leq qq\leq xix_i\in pi,yip_i,y_i\leq
131\sim 3 1010 {1,2,3,4}\{1,2,3,4\} 10910^9
44 10510^5 {1}\{1\}
575\sim 7 100100 {1,2,3,4}\{1,2,3,4\} 10001000
898\sim 9 10510^5 10510^5 {1,2}\{1,2\} 10910^9
101310\sim 13 {1,2,4}\{1,2,4\}
141714\sim 17 1010 {1,2,3,4}\{1,2,3,4\}
182018\sim 20 10510^5

Translated by ChatGPT 5