問題一覧 > 通常問題

No.1748 Parking Lot

レベル : / AI推定難易度 : 1100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 163
作問者 : 👑 箱星 / テスター : ramdos
お気に入りにしたユーザー ProblemId : 7146 / 自分の提出
問題文最終更新日: 2022-04-26 00:13:57
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 323 (順位表) の他の問題:

Problem Statement

A parking lot has parking spaces numbered from $1$ to $N$. $N$ cars are about to park here.

The first car parked in space number $K$.

The comfort of space number $x$ is the minimum absolute difference between its number and the number of a space that is already occupied. Formally, it is defined as follows.

$$ (\text{番号 }x\text{ のスペースの快適さ}) := \min\{|x-y|\mid \text{番号 }y\text{ のスペースに駐車されている}\} $$

Each subsequent car parks in the space with the maximum comfort among the unoccupied spaces. If there are multiple such spaces, it parks in the one with the smallest number.

What is the number of the space in which the $N$-th car parks?

Constraints

  • $1\le K\le N\le 10^9$
  • All input values are integers.

Input

$N$ $K$

Output

Output the number of the space in which the $N$-th car parks.

Sample

Sample 1
Input
4 2
Output
3

The first car parks in space $2$.

The $2$-nd car parks in space $4$, whose comfort is $2$.

After that, spaces $1,3$ have the same comfort, so the $3$-rd car parks in space $1$, which has the smaller number.

The $4$-th car parks in space $3$, so the answer is $3$.

Sample 2
Input
2 1
Output
2

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