P6784 "EZEC-3" Building a House

Background

pigstd is going to build a house.

Description

pigstd has $a$ units of material A and $b$ units of material B. Building the $i$-th floor requires $i$ units of material A and $i$ units of material B. However, pigstd thinks the house is not tall enough, so he takes out $c$ dollars. Each dollar can be used to buy $1$ unit of material A or $1$ unit of material B. Now pigstd wants to know the maximum number of floors he can build.

Input Format

The first line contains three integers $a, b, c$.

Output Format

Output one integer per line, representing the maximum number of floors pigstd can build.

Explanation/Hint

**[Sample 1 Explanation]** After pigstd buys $2$ units of material A and $1$ unit of material B, he will have $3$ units of material A and $3$ units of material B, so he can build at most a $2$-floor house. (It costs $(1 + 2)$ units of material A and $(1 + 2)$ units of material B.) **[Sample 2 Explanation]** After pigstd buys $3$ units of material A, he will have $4$ units of material A and $5$ units of material B, so he can build at most a $2$-floor house. (It costs $(1 + 2)$ units of material A and $(1 + 2)$ units of material B.) **[Constraints]** For $100\%$ of the testdata, $0 \le a, b, c \le 10^{12}$. | Test Point ID | Conditions Satisfied | | :----------: | :----------: | | $1-4,22$ | $c = 0$ | | $5-8,21$ | $a, b, c \le 10^{3}$ | | $9-12$ | $a, b, c \le 10^{6}$ | | $13-20$ | $a, b, c \le 10^{12}$ | Translated by ChatGPT 5