Codeforces Round 156 (Div. 2)
D
Mr. Bender and Square
Codeforces
1800
原题
← CE →
翻译中…

Mr. Bender has a digital table of size $*n* × *n*$, each cell can be switched on or off. He wants the field to have at least $*c*$ switched on squares. When this condition is fulfilled, Mr Bender will be happy.

翻译中…

We'll consider the table rows numbered from top to bottom from 1 to $*n*$, and the columns — numbered from left to right from 1 to $*n*$. Initially there is exactly one switched on cell with coordinates $(*x*, *y*)$ ($*x*$ is the row number, $*y*$ is the column number), and all other cells are switched off. Then each second we switch on the cells that are off but have the side-adjacent cells that are on.

翻译中…

For a cell with coordinates $(*x*, *y*)$ the side-adjacent cells are cells with coordinates $(*x* - 1, *y*)$, $(*x* + 1, *y*)$, $(*x*, *y* - 1)$, $(*x*, *y* + 1)$.

翻译中…

In how many seconds will Mr. Bender get happy?

翻译中…

Input

翻译中…

The first line contains four space-separated integers $*n*, *x*, *y*, *c*$ $(1 ≤ *n*, *c* ≤ 10^{9}; 1 ≤ *x*, *y* ≤ *n*; *c* ≤ *n*^{2})$.

翻译中…

Output

翻译中…

In a single line print a single integer — the answer to the problem.

翻译中…

Note

翻译中…

Initially the first test has one painted cell, so the answer is 0. In the second test all events will go as is shown on the figure. image.

翻译中…

样例

Input #1
6 4 3 1
Output #1
0
InputCopy OutputCopy
Input #2
9 3 8 10
Output #2
2
InputCopy OutputCopy
题目信息
题号
255D
时间限制
2 s
内存限制
256 MB
标签
二分
模拟
数学

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