luogu#P8593. 「KDOI-02」一个弹的投

    ID: 7244 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学线段树树状数组2022洛谷原创O2优化

「KDOI-02」一个弹的投

Background

  • Prerequisite knowledge: Projectile motion
    (If you do not want to do this after seeing it, you can directly move on to the next problem.)

"Those damn aliens must be here to seize new mineral resources!"
"What the heck is this missile? I cannot figure it out."
Countless droplet-shaped weapons fall from beyond the sky, striking ignorant life fiercely.

Problem Description

After research, the weapon works as follows. Let the direction of gravity be the negative half-axis of the yy axis, let the xx axis be the ground, and define velocity to the right as positive and to the left as negative.

  • Each missile is released and hovers at (xi,yi)(x_i, y_i), with initial velocity set to viv_i.
  • After all missiles have been released, they all start projectile motion at the same moment according to their initial velocities. Here g=9.8g=9.8.
  • When a missile collides with another missile, it will not change its original trajectory, and its explosive power pip_i increases by 11. Initially, all missiles have pi=0p_i=0. A collision when touching the xx axis also increases the power.
  • When a missile reaches the xx axis, it deals pip_i points of damage to its landing point.

The ground command predicted the landing points of the missiles in advance and deployed countermeasure weapons. The ii-th weapon can reduce the power value of the ii-th missile by aia_i after it lands (reducing it to at least 00). However, due to technical limitations, only mm countermeasure weapons can be activated. The commander wants to know what the minimum possible total explosive power value of all missiles is.

Input Format

Read from standard input.

The input contains a total of n+2n+2 lines.

Line 11 contains two positive integers n,mn, m.

Lines 22 to n+1n+1 each contain three integers xi,yi,vix_i, y_i, v_i, representing the starting coordinates and horizontal velocity of the ii-th missile.

Line n+2n+2 contains nn non-negative integers a1,a2,,ana_1, a_2, \cdots, a_n, with meanings as described above.

Output Format

Write to standard output.

Output one line with one non-negative integer, representing the answer.

3 0
1 1 -2
1 2 -1
1 3 1
1 1 1
0
4 1
-3 3 0
1 3 1
4 3 -4
-9 3 -7
1 3 2 3
1
见附件中的 missile3.in
见附件中的 missile3.ans
见附件中的 missile4.in
见附件中的 missile4.ans

Hint

Sample Explanation

  • Sample 1 Explanation:

    The explosive power value of each missile is 00.

  • Sample 2 Explanation:

    The explosive power values of the four missiles are 0,1,1,00, 1, 1, 0. Activate the 22-nd or the 33-rd countermeasure weapon, and the final sum of explosive power values is 11.

  • Sample 4 Note:

    This sample satisfies the constraints of test points 131613\sim16.


Constraints

For 100%100\% of the data, 1n5×1051 \le n \le 5 \times 10^5, 0ai,mn0 \le a_i, m \le n, 0xi,yi1090 \le |x_i|, y_i \le 10^9, 0vi1060 \le |v_i| \le 10^6.

It is guaranteed that all missiles have distinct starting coordinates.

Test Point ID nn \le Special Property
161\sim6 50005000 None
7107\sim10 1200012000
111211\sim12 10510^5 Yes
131613\sim16 None
172017\sim20 5×1055\times10^5

Special property: it is guaranteed that all yiy_i are the same.

Hint

This problem has a large amount of I/O, so a faster I/O method is recommended.

Landing point formula for projectile motion:

xt=xi+vi2yigx_t=x_i+v_i\sqrt{\dfrac{2y_i}g}

Translated by ChatGPT 5