#K71627. Distribute Candies
Distribute Candies
Distribute Candies
Given an integer n which represents the total number of candies, determine the maximum number of participants that can receive candies such that:
- Each participant gets at least one candy.
- No two participants receive the same number of candies.
This is equivalent to finding the maximum integer \( k \) such that the sum of the first \( k \) natural numbers satisfies \(\frac{k(k+1)}{2} \leq n\).
Example: When n = 7, the maximum number of participants is 3, because \(1+2+3=6\) and adding the next distinct candy count (4) would exceed 7.
inputFormat
The input consists of a single integer n (\(1 \leq n \leq 10^9\)) representing the total number of candies. The input is read from standard input (stdin).
outputFormat
Output a single integer, which is the maximum number of participants that can each receive a unique positive number of candies, satisfying the conditions described above. The output should be written to standard output (stdout).
## sample7
3
</p>