No.1748 Parking Lot
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もしくは右上の雲マークをクリックしてアカウントを作成してください。