TopcoderARCHIVE
Archive/Problems/EllysIncinerator
TCO · Problem 16217

EllysIncinerator

Problem statement, definition, constraints, and public examples.

Problem Statement

The government of the country, where Elly lives, thinks that the air there is too clean. To fix this, they want to build an incinerator, which burns waste.

For some unknown reason, the citizens started protesting. They had the absurd claim that the country was already burning enough coal and waste in its thermal power stations. Now the government thinks how to realize its project without making too much noise.

We can represent the country as a square 1000 by 1000 kilometers. There are several thermal power plants (TPS) inside it, which we'll represent as points with coordinates (X[i], Y[i]), laying inside or on the borders of this square. The TPS have different capacities. We'll consider the smoke cloud generated by each of them as a circle with radius R[i] and center the point (X[i], Y[i]). Since people have protested before because of the polu… clean air, the TPS are built in such a way that the smoke clouds of no two of them overlap (they are allowed to touch though).

Now the government has decided that if they make the incinerator follow the same rules people would stop protesting. For that, they need to find such a position and capacity for it, so its smoke cloud would not overlap with the smoke cloud of any of the TPS. Of course, they want the incinerator to be as powerful as possible, thus its radius should be as large as possible. Its coordinates should be inside or on the border of the country, however its smoke cloud (as well as the smoke clouds of the TPS) can go outside it.

You are given the double[]s X, Y and R giving the coordinates and the radius of each of the TPS. Return the maximum radius of the incinerator if positioned optimally.

Definition

Class:
EllysIncinerator
Method:
getMax
Parameters:
double[], double[], double[]
Returns:
double
Method signature:
double getMax(double[] X, double[] Y, double[] R)
(be sure your method is public)

Notes

  • Your return value will be considered correct if it has relative or an absolute error of less than 1e-9.

Constraints

  • X, Y and R will contain between 2 and 100 elements, inclusive.
  • X, Y and R will contain the same number of elements.
  • Each element of X and Y will be between 0 and 1000, inclusive.
  • Each element of R will be between 1 and 1414, inclusive.
  • All the input circles will not overlap, but may touch.

Examples

  1. {42.1337, 543.21, 987.987, 0, 666.666, 133.331, 888.8}
    {13.666, 765.432, 666.666, 1000, 66.66, 666.666666666, 88.8}
    {191.17, 55.555, 321.321, 100, 16.6, 123.321, 8.8}
    Returns: 320.33719645669953
    The answer is achieved with the incinerator being at coordinates (434.939950686, 341.298204535).
  2. {0, 1000}
    {0, 1000}
    {666, 666}
    Returns: 334.0000000000005
    Two termal plants at the opposite corners of the country.
  3. {0, 0, 1000, 1000}
    {0, 1000, 0, 1000}
    {13, 42, 17, 55}
    Returns: 673.3140001931692
  4. {827.471, 14.129, 618.708, 476.184, 809.486, 159.701, 43.542, 217.328, 520.811, 487.601,
     304.607, 71.408, 580.637, 431.44, 24.895, 56.299, 9.497, 739.488, 662.694, 120.741,
     926.914, 339.471, 276.891, 283.293, 992.381, 900.847, 923.426, 245.573, 990.897, 272.343,
     137.418, 165.462, 977.63, 865.129, 434.287, 660.135, 698.627, 58.002, 606.568, 336.6,
     993.813, 90.582, 585.609, 269.735, 992.49, 659.948, 526.141, 81.724, 223.153, 469.335}
    {880.162, 746.768, 230.709, 795.253, 586.775, 959.95, 117.509, 677.183, 548.965, 24.335,
     470.169, 788.348, 361.403, 576.748, 642.461, 875.51, 318.453, 666.799, 724.513, 400.208,
     26.04, 209.771, 272.209, 638.333, 759.456, 499.977, 332.563, 946.253, 919.925, 34.973,
     685.423, 847.907, 405.094, 342.004, 187.919, 67.409, 502.555, 747.495, 45.324, 296.785,
     636.987, 985.778, 594.304, 849.649, 299.628, 985.759, 415.145, 488.322, 825.231, 338.399}
    {133.779, 11.522, 120.985, 180.029, 53.259, 1.206, 191.179, 43.29, 21.854, 70.408,
     133.972, 6.499, 10.191, 14.466, 54.393, 44.575, 1.007, 32.116, 3.19, 48.873,
     187.111, 29.704, 41.875, 32.19, 1.18, 52.696, 37.619, 16.1, 1.864, 17.377,
     5.939, 23.41, 49.367, 4.069, 48.236, 3.956, 71.83, 14.036, 13.614, 2.498,
     73.595, 14.513, 43.772, 4.456, 16.72, 24.049, 41.104, 14.412, 19.842, 50.129}
    Returns: 86.72241709552333
← All problems