...Can you replicate my master thesis in 5 hours?
Yosupo
You are given N red points and N blue points on a two dimensional plane. The i-th red point's coordinate is (rx_i,ry_i), and its weight is rw_i. The i-th blue point's coordinate is (bx_i,by_i), and its weight is bw_i.
Process Q queries. In the i-th query, you are given two integers L_i and R_i, and choose a red point j and a blue point k with following conditions:
Your task is to maximize the sum of weights of the two points or report that it is impossible to select two points.
Input is given from Standard Input in the following format:
N
rx_1 ry_1 rw_1
⋮
rx_N ry_N rw_N
bx_1 by_1 bw_1
⋮
bx_N by_N bw_N
Q
L_1 R_2
⋮
L_Q R_Q
For each query, in a line, print the maximum sum of weights of the selected points, or −1 if it is impossible to choose two points.