eolymp
bolt
Try our new interface for solving problems
Problems

Let There Be Light

Let There Be Light

You want the total illumination intensity at an objective point as high as possible. For this purpose, some of the balloons obstructing lights can be removed. Because of the removal costs, however, there is a certain limit on the number of balloons to be removed. Thus, you would like to remove an appropriate set of balloons so as to maximize the illumination intensity at the objective point. The following gure illustrates the con guration speci ed in the first dataset of the sample input given below. The figure shows the \textbf{xy}-plane, which is enough because, in this dataset, the \textbf{z}-coordinates of all the light sources, balloon centers, and the objective point are zero. In the figure, light sources are shown as stars and balloons as circles. The objective point is at the origin, and you may remove up to \textbf{4} balloons. In this case, the dashed circles in the gure correspond to the balloons to be removed. \includegraphics{https://static.e-olymp.com/content/75/759e15b411c64d43af93eb7018d8a18c8c8b101d.jpg} \textit{\textbf{Figure 1}}: First dataset of the sample input. \InputFile The input is a sequence of datasets. Each dataset is formatted as follows. \textbf{N M R} \textbf{S_1x S_1y S_1z S_1r} \textbf{...} \textbf{S_Nx S_Ny S_Nz S_Nr} \textbf{T_1x T_1y T_1z T_1b} \textbf{...} \textbf{T_Mx T_My T_Mz T_Mb} \textbf{E_x E_y E_z} The first line of a dataset contains three positive integers, \textbf{N}, \textbf{M} and \textbf{R}, separated by a single space. \textbf{N} means the number of balloons that does not exceed \textbf{2000}. \textbf{M} means the number of light sources that does not exceed \textbf{15}. \textbf{R }means the number of balloons that may be removed, which does not exceed \textbf{N}. Each of the \textbf{N} lines following the first line contains four integers separated by a single space. \textbf{(S_ix, S_iy, S_iz)} means the center position of the \textbf{i}-th balloon and \textbf{S_ir} means its radius. Each of the following \textbf{M} lines contains four integers separated by a single space. \textbf{(T_jx, T_jy, T_jz)} means the position of the \textbf{j}-th light source and \textbf{T_jb} means its brightness. The last line of a dataset contains three integers separated by a single space. \textbf{(E_x, E_y, E_z)} means the position of the objective point. \textbf{S_ix}, \textbf{S_iy}, \textbf{S_iz}, \textbf{T_jx}, \textbf{T_jy}, \textbf{T_jz}, \textbf{E_x}, \textbf{E_y} and \textbf{E_z} are greater than \textbf{-500}, and less than \textbf{500}. \textbf{S_ir} is greater than \textbf{0}, and less than \textbf{500}. \textbf{T_jb} is greater than \textbf{0}, and less than \textbf{80000}. At the objective point, the intensity of the light from the \textbf{j}-th light source is in inverse proportion to the square of the distance, namely \includegraphics{https://static.e-olymp.com/content/db/db3b1d6d8acf6c668a27e27a4f0f89a621426a60.jpg} if there is no balloon interrupting the light. The total illumination intensity is the sum of the above. You may assume the following. \begin{itemize} \item The distance between the objective point and any light source is not less than \textbf{1}. \item For every \textbf{i} and \textbf{j}, even if \textbf{S_ir} changes by \textbf{ϵ} (\textbf{|ϵ|} < \textbf{0.01}), whether the \textbf{i}-th balloon hides the \textbf{j}-th light or not does not change. \end{itemize} The end of the input is indicated by a line of three zeros. \OutputFile For each dataset, output a line containing a decimal fraction which means the highest possible illumination intensity at the objective point after removing \textbf{R} balloons. The output should not contain an error greater than \textbf{0.0001}.
Time limit 30 seconds
Memory limit 128 MiB
Input example #1
12 5 4
0 10 0 1
1 5 0 2
1 4 0 2
0 0 0 2
10 0 0 1
3 -1 0 2
5 -1 0 2
10 10 0 15
0 -10 0 1
10 -10 0 1
-10 -10 0 1
10 10 0 1
0 10 0 240
10 0 0 200
10 -2 0 52
-10 0 0 100
1 1 0 2
0 0 0
12 5 4
0 10 0 1
1 5 0 2
1 4 0 2
0 0 0 2
10 0 0 1
3 -1 0 2
5 -1 0 2
10 10 0 15
0 -10 0 1
10 -10 0 1
-10 -10 0 1
10 10 0 1
0 10 0 260
10 0 0 200
10 -2 0 52
-10 0 0 100
1 1 0 2
0 0 0
5 1 3
1 2 0 2
-1 8 -1 8
-2 -3 5 6
-2 1 3 3
-4 2 3 5
1 1 2 7
0 0 0
5 1 2
1 2 0 2
-1 8 -1 8
-2 -3 5 6
-2 1 3 3
-4 2 3 5
1 1 2 7
0 0 0
0 0 0
Output example #1
3.5
3.6
1.1666666666666667
0.0
Source ACM International Collegiate Programming Contest, Asia Regional Contest, Tokyo, 2012-11-18