#P2440. Maximal Uniform Wood Cutting
Maximal Uniform Wood Cutting
Maximal Uniform Wood Cutting
A lumber mill has n logs. The goal is to cut these logs into k pieces, each of exactly the same integer length l (in centimeters). Note that there may be leftover wood on the logs that is discarded.
The objective is to maximize the length l of each piece. Determine the maximum possible l such that at least k pieces of length l cm can be obtained from the given logs. All the original log lengths and the resulting piece length are positive integers.
For example, if there are two logs of lengths 11 cm and 21 cm, and the task is to obtain 6 equal pieces, the maximum possible length for each piece is 5 cm.
inputFormat
The first line contains two positive integers n and k, representing the number of logs and the required number of pieces respectively.
The second line contains n positive integers, each indicating the length (in cm) of a log.
outputFormat
Output a single integer, the maximum possible length l (in cm) of each piece such that at least k pieces can be obtained.
sample
2 6
11 21
5