D. Drinking to turn red

Codeforces
IDCF10244D
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
After the closing ceremony of an ICPC competition, Lucas and his friend decided to go to the hotel pool to have some magical drinks. After a while, Lucas found a magic swim ring and also realized that the swim rings had some interesting properties: Assuming the pool is an infinite plane and the swim rings are located at points ($X_i$, $Y_i$) with radius $R_i$, Lucas would like to know the smallest possible radius, such that if he places a magic swim ring centered at the point ($x$, $y$), all swim rings would be absorbed by the magic ring. Example: In this example, the magic swim ring (red) would need a radius of at least 1 to absorb the blue swim ring. After absorption, its new radius would be equal to 4, and then it would be able to absorb the purple swim ring. The first line of input contains three integers $N$ ($0 < N <= 10^5$) and $x$, $y$ ($-10^9 < x, y <= 10^9$), the number of swim rings and the center of the magic swim ring. The $i$-th of the next $N$ lines contains three integers $X_i$, $Y_i$ ($-10^9 < X_i, Y_i <= 10^9$) and $R_i$($1 < R_i <= 10^5$), center and radius of the $i$-th swim ring. You must print the minimum radius the magic swim ring should have in order to solve Lucas' challenge. Your answer is considered correct if its absolute or relative error does not exceed $10^(-6)$. ## Input The first line of input contains three integers $N$ ($0 < N <= 10^5$) and $x$, $y$ ($-10^9 < x, y <= 10^9$), the number of swim rings and the center of the magic swim ring.The $i$-th of the next $N$ lines contains three integers $X_i$, $Y_i$ ($-10^9 < X_i, Y_i <= 10^9$) and $R_i$($1 < R_i <= 10^5$), center and radius of the $i$-th swim ring. ## Output You must print the minimum radius the magic swim ring should have in order to solve Lucas' challenge. Your answer is considered correct if its absolute or relative error does not exceed $10^(-6)$. [samples]
**Definitions** Let $ N \in \mathbb{Z}^+ $ be the number of swim rings. Let $ (x, y) \in \mathbb{R}^2 $ be the center of the magic swim ring. For each $ i \in \{1, \dots, N\} $, let $ (X_i, Y_i) \in \mathbb{R}^2 $ be the center and $ R_i \in \mathbb{R}^+ $ the radius of the $ i $-th swim ring. **Constraints** 1. $ 0 < N \leq 10^5 $ 2. $ -10^9 \leq x, y \leq 10^9 $ 3. $ -10^9 \leq X_i, Y_i \leq 10^9 $ 4. $ 1 < R_i \leq 10^5 $ **Objective** Find the minimum radius $ r \in \mathbb{R}^+ $ such that the magic swim ring centered at $ (x, y) $ with radius $ r $ can absorb all swim rings, where absorption of a ring at $ (X_i, Y_i) $ with radius $ R_i $ requires: $$ r \geq \sqrt{(x - X_i)^2 + (y - Y_i)^2} + R_i $$ Thus, the required minimum radius is: $$ r = \max_{1 \leq i \leq N} \left( \sqrt{(x - X_i)^2 + (y - Y_i)^2} + R_i \right) $$
API Response (JSON)
{
  "problem": {
    "name": "D. Drinking to turn red",
    "description": {
      "content": "After the closing ceremony of an ICPC competition, Lucas and his friend decided to go to the hotel pool to have some magical drinks. After a while, Lucas found a magic swim ring and also realized that",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10244D"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "After the closing ceremony of an ICPC competition, Lucas and his friend decided to go to the hotel pool to have some magical drinks. After a while, Lucas found a magic swim ring and also realized that...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the number of swim rings.  \nLet $ (x, y) \\in \\mathbb{R}^2 $ be the center of the magic swim ring.  \nFor each $ i \\in \\{1, \\dots, N\\} $, let $ (X_i, Y_i)...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments