#K64832. Maximum Distinct Rope Splits
Maximum Distinct Rope Splits
Maximum Distinct Rope Splits
You are given a rope of length L. Your task is to determine the maximum number of distinct positive integers (lengths) such that the sum of these integers does not exceed L. In other words, you need to split the rope into as many pieces as possible, with each piece having a unique (distinct) positive integer length.
This problem can be mathematically formulated as finding the maximum integer k such that:
\( 1 + 2 + 3 + \dots + k = \frac{k(k+1)}{2} \le L \)
For example, if L = 7, the answer is 3 because you can cut the rope into pieces of lengths 1, 2, and 4.
inputFormat
The input consists of a single integer L (1 \leq L \leq 10^9
) denoting the length of the rope.
outputFormat
Output a single integer representing the maximum number of distinct parts into which the rope can be cut. The answer satisfies the inequality \( \frac{k(k+1)}{2} \le L \).
## sample7
3