#P5996. [PA 2014] Muzeum

[PA 2014] Muzeum

Description

Gili’s convention has nn figurines and mm guards.

Now we build a 2D Cartesian coordinate system for it. Each figurine and each guard can be regarded as a point. All guards look toward the negative direction of the yy-axis, and they all have the same field of view. A guard can see all figurines inside its field of view (including points on the boundary). You do not need to consider any blocking of the line of sight.

You plan to rob Gili’s convention, but you do not want to be discovered by the guards. To carry out this plan, you may bribe some guards in advance to make them close their eyes. As long as a figurine is not in the field of view of any guard whose eyes are open, you can steal it. You know the price of each figurine and the amount of money required to bribe each guard. You want to know your maximum profit.

It is guaranteed that each point contains at most one figurine or one guard.

Input Format

The first line contains two integers n,mn, m, representing the number of figurines and the number of guards.

The second line contains two integers w,hw, h, meaning that the tangent of half of each guard’s viewing angle is wh\dfrac{w}{h}. (See the figure.)

The next nn lines each contain three integers xi,yi,vix_i, y_i, v_i, meaning that the figurine is at (xi,yi)(x_i, y_i) and its price is viv_i.

The next mm lines have the same format, meaning that the guard is at (xi,yi)(x_i, y_i) and the bribe amount required is viv_i.

Output Format

Output one line containing the maximum profit.

5 3
2 3
2 6 2
5 1 3
5 5 8
7 3 4
8 6 1
3 8 3
4 3 5
5 7 6
6

Hint

For 100%100\% of the testdata, 1n,m2×1051\le n,m\le 2\times 10^5, 1w,h1091\le w,h\le 10^9, 109xi,yi109-10^9\le x_i,y_i\le 10^9, 1vi1091\le v_i\le 10^9.


Sample Explanation

Bribe two guards whose total bribe is 3+6=93+6=9, and steal 44 figurines whose total value is 2+8+4+1=152+8+4+1=15, so the profit is 159=615-9=6.

Translated by ChatGPT 5