問題一覧 > ⚠未証明/不備あり問題

No.853 Stones on the Riverbank

レベル : / 実行時間制限 : 1ケース 3.153秒 / メモリ制限 : 315 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 7
作問者 : CuriousFairy315 / テスター : Enjapma_kyopro
お気に入りにしたユーザー ProblemId : 3201 / 自分の提出
問題文最終更新日: 2020-06-14 02:34:46
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 218 (順位表) の他の問題:

Problem Statement

It has been discovered that the intended solution is incorrect!!! We are sorry!!!


For the time being, we will make submitted code result in NoOut.For operational reasons, we will leave this as it was when it was set.
The original problem statement follows.

31536000 is playing a game of piling up stones on a riverbank.
This riverbank extends infinitely in the horizontal direction, and at every position there is a tower consisting of $0$ levels of stones.
Now, 31536000 has built one tower consisting of $H$ levels of stones right in front of them.
However, a scary demon that tries to knock down stone towers lives on this riverbank.
31536000 noticed that the demon will soon come here, and decided to move the tower.
From now on, 31536000 can perform the following operation.
・Choose one tower consisting of $1$ or more levels of stones, and move one stone to a different tower within a distance of at most the number of levels of stones in the tower. In other words, letting $x$ be the position of the tower and $y$ be its number of levels of stones, choose one tower within $[x-y, x+y]$ and move one stone to that tower.
When performing this operation some number of times to build a tower consisting of $H$ levels of stones at the position a distance $W$ away from here in the positive direction, find the minimum number of operations.

Input

$H$ $W$

・$0 \leq H \leq 10^9$
・$-10^9 \leq W \leq 10^9$

Output

Output the minimum number of operations required.
Print a newline at the end.

Sample

Sample 1
Input
2 1
Output
2

The operations are as follows.
1. Move one stone from the tower at the origin to coordinate $1$.
2. Move one stone from the tower at the origin to coordinate $1$.

Sample 2
Input
3 2
Output
4

The operations are as follows.
1. Move one stone from the tower at the origin to coordinate $2$.
2. Move one stone from the tower at the origin to coordinate $2$.
3. Move one stone from the tower at the origin to coordinate $1$.
4. Move one stone from the tower at coordinate $1$ to coordinate $2$.
Note that at the time of the 3rd operation, the tower at the origin consists of $1$ level, so a stone cannot be placed directly at coordinate $2$.

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