124 - ZOJ Monthly, March 2013 - F
Gao and his girlfriend's relationship becomes better and better after they flying balloon last week. Thus, Gao wants to play a simple but evil game with his girlfriend at a late night.
The game is simple: there is a three-dimensional space, Gao chooses N points to put flowers. For the point i, it has Fi flowers. And his girlfriend has to move all these flowers to point 1 altogether. As everyone knows, his girlfriend is not strong like Gao, so she can move flowers from one point to another if and only if the Euclidean distance between two points are smaller or equal to R. In another words, she perhaps has to move flowers to the intermediate point for finally moving all flowers to the point one. In order to stay with his girlfriend as much time as possible, he asks his girlfriend, for the point i, that she can only move out no more than Li flowers (including the points as an intermediate point).
Can you help his poor girlfriend to calculate the minimal R?
There are multiple cases.
For each case, the first line contains an integer N (1 ≤ N ≤ 100), which means there are N points.
For the next N lines, each line contains five integers, Xi, Yi, Zi, Fi and Li. Xi, Yi and Zi are the coordinate of point i (0 ≤ Xi, Yi, Zi ≤ 20000), Fi means there are Fi flowers at the beginning. Li means this point can be moved out no more than Li flowers.
For each test case, it contains one real number indicating the minimal R. The results should be rounded to seven decimal places. If there is no solution for this case, please output -1. Output's absolute error less than 1e-6 will be accepted.
2 1 1 1 1 1 2 2 2 2 2
Author: REN, Qing