TVAntenna
SRM 183 · 2004-02-11 · by dgoodman
Problem Statement
We have
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 -200 and 200 inclusive.
{2,0,0,1}
{0,1,-1,1}
Returns: 1.4142135623730951
The towns are located at (2,0), (0,1), (0,-1) and (1,1). The obvious location for the antenna is at (1,0). From there the distances to the four towns are 1, sqrt(2), sqrt(2) and 1, so a broadcast radius of sqrt(2) will reach all four towns. The next best location for the antenna at integer coordinates would be at (1,1) but then one of the towns would be sqrt(5) away from the antenna.
{3}
{99}
Returns: 0.0
Locate the tower right in the one town.
{200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200}
{200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200,200}
Returns: 0.0
{200,-200,4,8,23,-129}
{-200,200,138,-123,2,4}
Returns: 282.842712474619
{-199,-199,-199,-199}
{-50,-100,-70,-69}
Returns: 25.0
Submissions are judged against all 24 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TVAntenna with a public method double minRadius(vector<int> x, vector<int> y) · 24 test cases · 2 s / 256 MB per case