問題一覧 > 通常問題

No.172 Catch the UFO

レベル : / AI推定難易度 : 650 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 542
作問者 : threepipes_s
お気に入りにしたユーザー ProblemId : 388 / 自分の提出
問題文最終更新日: 2026-06-25 09:40:20
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 94 (順位表) の他の問題:

Problem Statement

Yuki-chan is on her daily walk with her beloved dog Ruby.
However, a UFO suddenly appeared, abducted Ruby and fled.
To rescue Ruby, unleash Yuki-chan's psychic powers and catch the UFO!

Yuki-chan, who is at coordinates $(0, 0)$, can use her psychic powers to instantly create a barrier whose Manhattan distance to its boundary is a natural number.
The UFO is a circle with current position $(x, y)$ and radius $r$, and the capture succeeds if the UFO is inside the barrier when the barrier is created.
Note that if the UFO is touching the created barrier at this time, it will get away. (*)

Yuki-chan wants to conserve her power in preparation for other UFO attacks, so she wants to keep the size of the barrier to a minimum.
Output the minimum size of the barrier to create in order to capture the UFO.


*The barrier is sufficiently thin, so the UFO touching the boundary refers to the following state:
there exists a point P that is contained on the boundary of or inside the UFO and is also located on the boundary of the barrier.

Input

x y r

The input is given in one line.
The UFO is at coordinates $(x, y)$ and its radius is $r$.
The constraints on each input are as follows, and all inputs are integers.
$-100\le x\le100$
$-100\le y\le100$
$1\le r\le100$

Also, the coordinates where Yuki-chan is located are $(0, 0)$.

Output

Output the size of the barrier Yuki-chan creates (the Manhattan distance from Yuki-chan to the boundary) in one line.

Sample

Sample 1
Input
2 2 1
Output
6

By creating a barrier with Manhattan distance 6 to its boundary, the UFO can be confined inside the barrier.
Since Yuki-chan is at coordinates (0, 0), the barrier (green) and the UFO (red) look like the figure below.

Sample 2
Input
-50 -40 30
Output
133

The UFO fled quite far away, but it is soon caught by Yuki-chan's hand.

Sample 3
Input
0 0 100
Output
142

Unfortunately, the UFO was caught by Yuki-chan before it had any time to flee.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。