#P12269. Optimal Wooden Rod Cutting

    ID: 14377 Type: Default 1000ms 256MiB

Optimal Wooden Rod Cutting

Optimal Wooden Rod Cutting

You are given n wooden rods. The length of the i-th rod is \( L_i \). In each operation, you can choose any rod and cut it into two parts. After the cut, both resulting segments must have integer lengths.

You are allowed to perform exactly \( m \) cuts in total. Among all the possible cutting strategies, determine the minimum possible value of the maximum length among all the rod pieces after all cuts have been made.

Note: When a rod of length \( L \) is cut to ensure that no piece is longer than \( x \), you need to make at least \( \lceil \frac{L}{x} \rceil - 1 \) cuts on that rod.

inputFormat

The first line contains two integers \( n \) and \( m \) denoting the number of wooden rods and the total number of cuts allowed, respectively.

The second line contains \( n \) space-separated integers \( L_1, L_2, \ldots, L_n \) representing the lengths of the wooden rods.

outputFormat

Output a single integer which is the minimum possible value of the maximum length of the rod pieces after exactly \( m \) cuts.

sample

3 5
7 5 9
3