#P3344. Wi‑Fi Coverage in the Sunflower Field
Wi‑Fi Coverage in the Sunflower Field
Wi‑Fi Coverage in the Sunflower Field
In Gensokyo, the tsundere girl Youko has discovered that no one visits her sunflower field anymore. She found out that visitors dislike the lack of Wi‑Fi. Determined to bring back the crowds, Youko plans to set up several Wi‑Fi routers in the field. The sunflower field is approximated by an infinitely long horizontal rectangle with its y‑coordinate spanning from 0 to R and its x‑coordinate extending over \( (-\infty, +\infty) \).
There are n scenic spots in the field that are frequently visited by tourists. Youko believes that if most scenic spots are covered by Wi‑Fi, the visitors will surely be satisfied.
Eight Clouds Youmu offers to help by installing routers. However, the routers available have a fixed coverage radius of \(R\) and can only be installed at m given candidate locations outside the sunflower field (i.e. with network access). If a router is installed at point \( p \), then any point \( q \) will be covered by Wi‑Fi provided that their Euclidean distance satisfies \( \|p-q\| \le R \).
Youko wants to maximize the number of scenic spots covered. In the event of multiple choices achieving the maximum coverage, she wishes to minimize the total installation cost. Each candidate installation point \( i \) comes with a cost \( c_i \).
Your task is to help Youko select a subset of candidate locations such that the number of scenic spots covered is maximized and, among all such selections, the total cost is minimized.
Note: All scenic spots lie within the field, i.e. their y-coordinate satisfies \(0 \le y \le R\). Also, if no router is installed, the coverage is considered to be 0 and the total cost is 0.
inputFormat
The input is given as follows:
The first line contains three values: an integer (n) (the number of scenic spots), an integer (m) (the number of candidate router installation locations), and a number (R) (the router coverage radius).
Then follow (n) lines, each containing two space-separated numbers (x) and (y), representing the coordinates of a scenic spot (note that (0 \le y \le R)).
Finally, there are (m) lines, each containing three space-separated numbers: (x), (y), and (c). Here, ((x, y)) is the candidate router location and (c) (an integer) is the installation cost at that location.
outputFormat
Output two integers separated by a space:
- The maximum number of scenic spots that can be covered by the installed routers.
- The minimum total installation cost required to achieve that maximum coverage.
sample
3 2 5
0 0
3 4
7 2
0 -3 10
5 7 15
2 25