#P8061. Bomb Explosion Optimization
Bomb Explosion Optimization
Bomb Explosion Optimization
JYY has built (N) circular buildings on a 2D map. The (i)-th building is a circle with center ((x_i,y_i)) and radius (r_i). There are also (M) enemies on the map, each represented as a point ((p_i,q_i)). JYY has one bomb whose explosion radius can be set arbitrarily up to (R). When the bomb is detonated at some point ((X,Y)) with radius (r) ((0 \le r \le R)), all enemies inside or on the boundary of the explosion disc (i.e. all enemy points (E) with (|E - (X,Y)| \le r)) will be eliminated. However, for safety, if the explosion range intrudes into the interior region of any of JYY's own buildings, that building will be damaged. (Note that if the explosion disc touches the boundary of a building without penetrating its interior, the building is safe.) As a cautious player, JYY wants to maximize the number of enemies eliminated while guaranteeing no building is damaged. In other words, the explosion must be chosen so that for every building (i) the distance from the explosion center ((X,Y)) to the building center ((x_i,y_i)) satisfies [ | (X,Y) - (x_i,y_i) | \ge r + r_i, ] and additionally (r \le R).
Your task is to choose an explosion center ((X,Y)) and an explosion radius (r) (with (0\le r\le R)) satisfying the above safety condition and maximizing the number of enemy points ((p_i,q_i)) that lie within or on the explosion disc ({(x,y): \sqrt{(x-X)^2+(y-Y)^2}\le r}).
Note: The bomb explosion disc is allowed to touch (but not penetrate) any building's boundary.
inputFormat
The first line contains three numbers (N), (M), and (R), where (N) is the number of buildings, (M) is the number of enemies, and (R) is the maximum explosion radius you can set for the bomb. It is followed by (N) lines. The (i)-th of these lines contains three real numbers (x_i), (y_i), and (r_i) describing the center and radius of the (i)-th building. Then (M) lines follow; the (i)-th line contains two real numbers (p_i) and (q_i) representing the coordinates of the (i)-th enemy.
outputFormat
Output a single integer — the maximum number of enemies that can be eliminated by the bomb under the constraint that no building is damaged.
sample
1 3 5
0 0 1
2 0
4 0
0 4
2