Codeforces Round 393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition)
B
Frodo and pillows
Codeforces
1500
原题
← AC →
翻译中…

$*n*$ hobbits are planning to spend the night at Frodo's house. Frodo has $*n*$ beds standing in a row and $*m*$ pillows ($*n* ≤ *m*$). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if he has at least two pillows less than some of his neighbors have.

翻译中…

Frodo will sleep on the $*k*$-th bed in the row. What is the maximum number of pillows he can have so that every hobbit has at least one pillow, every pillow is given to some hobbit and no one is hurt?

翻译中…

Input

翻译中…

The only line contain three integers $*n*$, $*m*$ and $*k*$ ($1 ≤ *n* ≤ *m* ≤ 10^{9}$, $1 ≤ *k* ≤ *n*$) — the number of hobbits, the number of pillows and the number of Frodo's bed.

翻译中…

Output

翻译中…

Print single integer — the maximum number of pillows Frodo can have so that no one is hurt.

翻译中…

Note

翻译中…

In the first example Frodo can have at most two pillows. In this case, he can give two pillows to the hobbit on the first bed, and one pillow to each of the hobbits on the third and the fourth beds.

翻译中…

In the second example Frodo can take at most four pillows, giving three pillows to each of the others.

翻译中…

In the third example Frodo can take three pillows, giving two pillows to the hobbit in the middle and one pillow to the hobbit on the third bed.

翻译中…

样例

Input #1
4 6 2
Output #1
2
InputCopy OutputCopy
Input #2
3 10 3
Output #2
4
InputCopy OutputCopy
Input #3
3 6 1
Output #3
3
InputCopy OutputCopy
题目信息
题号
760B
时间限制
1 s
内存限制
256 MB
标签
二分
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。