TopCoder problem "TVTower" used in SRM 183 (Division I Level Two)



Problem Statement

    Our problem is where to locate our TV station's broadcasting tower. We know the locations of the towns we should serve. Fortunately, we are located on the flat, flat prairie, so the only issue is where to locate the tower to minimize the broadcast radius that includes all the towns.

We have int[] x and int[] y giving the locations of the towns; the i-th elements of x and y give the coordinates of the i-th town. Create a class TVTower that contains a method minRadius that is given x and y, and returns the minimum broadcast radius that can reach all the towns. The tower's location is NOT restricted to integer coordinates.

 

Definition

    
Class:TVTower
Method:minRadius
Parameters:int[], int[]
Returns:double
Method signature:double minRadius(int[] x, int[] y)
(be sure your method is public)
    
 

Notes

-If the return has either a relative or absolute error less than 1.0E-9 it is acceptable.
 

Constraints

-x will contain between 1 and 50 elements inclusive.
-y will contain the same number of elements as x.
-Each element in x and y will be between -1000 and 1000 inclusive.
 

Examples

0)
    
{1, 0, -1, 0}
{0, 1, 0, -1}
Returns: 1.0
By symmetry we should locate the tower at the origin, which is in the center of the diamond formed by these 4 towns.
1)
    
{3}
{299}
Returns: 0.0
Locate the tower right in the town.
2)
    
{5, 3, -4, 2}
{0, 4, 3, 2}
Returns: 4.743416490252569

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=2260

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=4735&pm=2260

Writer:

dgoodman

Testers:

lbackstrom , brett1479

Problem categories:

Geometry