Statistics

Problem Statement for "Flee"

Problem Statement

You are a point in the plane. You start at the coordinates (0, 0) and you want to flee far away, to the coordinates (10^100, 0). Your path can be any continuous curve.

You are given int[]s x and y. For each valid i, there is a guard standing on the point with coordinates (x[i], y[i]). The guards do not move. You want to avoid the guards as much as possible.

Formally, for any point P in the plane, we define its safety level S(P) as the distance to the closest guard. The safety level of a path is the minimum safety level of a point on the path. Find a path with the largest possible safety level and return its safety level.

Definition

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

Notes

  • Your return value must have an absolute or a relative error smaller than 1e-9.

Constraints

  • x will contain between 1 and 3 elements, inclusive.
  • x and y will contain the same number of elements.
  • Each element in x and y will be between -1,000 and 1,000, inclusive.

Examples

  1. {1,1,-7}

    {5,-5,0}

    Returns: 5.0

    You can go from (0, 0) to (10^100, 0) directly. The safety level of this path is 5, because when you are at (1, 0) the distance to the closest guard is 5.

  2. {1,1}

    {-5,-5}

    Returns: 5.0990195135927845

    One optimal path is the following polyline: (0, 0) -- (-100, 0) -- (-100, -10000) -- (10^100, 0).

  3. {1,1,-8}

    {5,-5,0}

    Returns: 5.0990195135927845

  4. {232,312,-432}

    {498,-374,24}

    Returns: 432.6661530556787

  5. {0}

    {0}

    Returns: 0.0

    Each valid path starts in the point (0, 0). This point contains a guard and therefore its safety level is 0. Hence, the safety level of any valid path will be 0.

  6. {-941}

    {-883}

    Returns: 1290.4146620369747

  7. {873}

    {728}

    Returns: 1136.7114849424192

  8. {102,620,-161}

    {781,-207,512}

    Returns: 536.7168713577018

  9. {-608}

    {933}

    Returns: 1113.6215694750167

  10. {-285}

    {-718}

    Returns: 772.4953074291132

  11. {-581,-81,-449}

    {530,-650,-214}

    Returns: 497.390188885949

  12. {708,774,-448}

    {-477,-770,-757}

    Returns: 853.6937389954314

  13. {-204,-74}

    {979,658}

    Returns: 662.1480197055639

  14. {-559,865,920}

    {-674,707,-127}

    Returns: 875.6466182199301

  15. {227}

    {861}

    Returns: 890.4212486233691

  16. {-567}

    {-94}

    Returns: 574.7390712314589

  17. {-947}

    {-679}

    Returns: 1165.2682094693905

  18. {4}

    {640}

    Returns: 640.012499877932

  19. {-282,959,500}

    {669,405,182}

    Returns: 532.0939766620179

  20. {577,705,391}

    {-912,328,-873}

    Returns: 777.5660743628157

  21. {475,-843}

    {-715,697}

    Returns: 858.3996738116807

  22. {-308,963}

    {412,-217}

    Returns: 514.4006220836052

  23. {-170,-290}

    {-325,-199}

    Returns: 351.7115295238415

  24. {-730,-625,-492}

    {770,-972,310}

    Returns: 581.5187013329837

  25. {359}

    {747}

    Returns: 828.7882721177948

  26. {-360,870,-966}

    {984,720,867}

    Returns: 1047.7862377412675

  27. {-487,-85,120}

    {944,-161,534}

    Returns: 182.06042952822008

  28. {310}

    {46}

    Returns: 313.39432030590467

  29. {-120}

    {-853}

    Returns: 861.3994427674074

  30. {-170,-325,525}

    {677,433,-719}

    Returns: 541.4000369412622

  31. {-676,-881,548}

    {-354,4,-915}

    Returns: 763.0805986263836

  32. {-827}

    {454}

    Returns: 943.421962856494

  33. {-109}

    {34}

    Returns: 114.17968295629481

  34. {-843,981}

    {-504,57}

    Returns: 982.1736099081465

  35. {465,166,-309}

    {36,-87,36}

    Returns: 187.4166481399131

  36. {-841}

    {283}

    Returns: 887.3387177397367

  37. {39,-177}

    {150,158}

    Returns: 154.9870962370739

  38. {32,751,206}

    {80,-553,-648}

    Returns: 86.16263691415207

  39. {976,-353}

    {-264,-202}

    Returns: 406.70997037200846

  40. {23,927}

    {-77,-833}

    Returns: 80.36168241145776

  41. {-110,560,70}

    {731,112,732}

    Returns: 571.090185522392

  42. {57}

    {731}

    Returns: 733.2189304702927

  43. {-843,-852}

    {208,736}

    Returns: 868.2816363369664

  44. {-863}

    {-194}

    Returns: 884.5366018430216

  45. {-416,-140,-295}

    {553,-410,560}

    Returns: 433.2435804486894

  46. {278}

    {-644}

    Returns: 701.4413731738384

  47. {472}

    {571}

    Returns: 740.8272403199007

  48. {-996,-915}

    {675,-276}

    Returns: 955.7201473234725

  49. {212,669,224}

    {592,-496,-473}

    Returns: 523.3593411796526

  50. {701,618,-984}

    {915,642,-783}

    Returns: 891.1161540450269

  51. {281}

    {-576}

    Returns: 640.8876656638042

  52. {-13,-710,-923}

    {368,164,-881}

    Returns: 368.229547972457

  53. {905,-552,521}

    {424,-761,-234}

    Returns: 571.1365861157906

  54. {-717,-769,102}

    {283,-703,406}

    Returns: 418.6167698504206

  55. {-231,-398,646}

    {-27,-562,-252}

    Returns: 232.57256931977167

  56. {849}

    {24}

    Returns: 849.3391548727752

  57. {216,751,868}

    {-965,233,-946}

    Returns: 786.314186569211

  58. {610}

    {-826}

    Returns: 1026.8281258321667

  59. {298,694}

    {-388,-737}

    Returns: 489.2320512803715

  60. {-493}

    {-631}

    Returns: 800.7558928912106

  61. {522}

    {-758}

    Returns: 920.3521065331463

  62. {803,61,-251}

    {-409,-800,-955}

    Returns: 802.3222544588925

  63. {169}

    {-518}

    Returns: 544.8715444946633

  64. {996}

    {-193}

    Returns: 1014.5269833769823

  65. {228,-265,-616}

    {-116,310,61}

    Returns: 255.8124312851117

  66. {100, 100, 100 }

    {-1, 0, 1 }

    Returns: 100.0

  67. {1, 1, -7 }

    {5, -5, 0 }

    Returns: 5.0

  68. {1, 1, 0 }

    {0, 0, 1 }

    Returns: 1.0

  69. {1, -7, 1 }

    {5, 0, -5 }

    Returns: 5.0

  70. {-1000 }

    {-1000 }

    Returns: 1414.213562373095

  71. {-1, 100, 100 }

    {100, 100, -1 }

    Returns: 100.00499987500623

  72. {100, 100, 101 }

    {100, 101, 100 }

    Returns: 141.4213562373095

  73. {1, 1, -8 }

    {5, -5, 0 }

    Returns: 5.0990195135927845

  74. {10, 11, 11 }

    {0, 1, -1 }

    Returns: 10.0

  75. {1, 1, 1 }

    {5, 5, 5 }

    Returns: 5.0990195135927845

  76. {-4, -5, -5 }

    {0, 1, -1 }

    Returns: 4.0

  77. {-500, -499, -501 }

    {-500, -501, -501 }

    Returns: 707.1067811865476


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: