Time limit per test:1 second
Memory limit per test:256 megabytes
N Hobbits is planning to spend the night at Frodo's house. Frodo have 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 had at least both pillows less than some of his neighbors has.
Frodo'll sleep on the k-th bed in the row. What's the maximum number of pillows he can have so that every hobbit had at least one pillow, every pillow was given to s Ome 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 Pillo WS and the number of Frodo ' s bed.
Output
Print single integer-the maximum number of pillows Frodo can has so and no one is hurt.
Examples
Input
4 6 2
Output
2
Input
3 10 3
Output
4
Input
3 6 1
Output
3
Note
1.In The first example Frodo can has at most of the pillows. In this case, he can give-pillows to The Hobbit on the first bed, and one pillow to each of the Hobbits on the third a nd the fourth beds.
2.In The second example Frodo can take at the very four pillows, giving three pillows to each of the others.
3.In The third example Frodo can take three pillows, giving of pillows to the Hobbit in the middle and one pillow to the Hobbit on the third bed.
Title Description:
There are n individuals, M pillows, the protagonist lying on the K-bed. Everyone sleeps at least a pillow, if a person and his next to a person using a different number of pillows 2 or more, then he will feel sad, ask in the case to ensure that everyone is not sad, the protagonist can use the maximum number of pillows.
The problem: (I think this topic I have the difficulty, already can abandon cure.) )
First, assign each person a pillow, and the answer is first 1. We can know that the main character is set to the highest point, and then to both sides of the decline can be reached.
Code:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#define Liangjiajun main
using namespace std;
int n,m,k,ans=1,reduc_;
int Liangjiajun () {
scanf ("%d%d%d", &n,&m,&k);
M-= n;
REDUC_ = 1;
if (M = = 0) return puts ("1"), 0;
while (m>0) {
if (k+ans<=n) ++reduc_;
if (k-ans>=1) ++reduc_;
M-= reduc_;
++ans;
}
printf ("%d\n", ans);
return 0;
}