#K48007. Smallest Divisor to Achieve Threshold Sum

    ID: 28324 Type: Default 1000ms 256MiB

Smallest Divisor to Achieve Threshold Sum

Smallest Divisor to Achieve Threshold Sum

You are given an array of positive integers A and a positive integer threshold T. Your task is to find the smallest divisor d such that the sum of the ceiling of each array element divided by d is less than or equal to T.

More formally, find the minimum positive integer d such that:

\(\sum_{i=1}^{N} \lceil \frac{A_i}{d} \rceil \le T\)

If such a divisor exists, output it. It is guaranteed that a solution exists for the input constraints.

inputFormat

The input consists of two lines:

  1. The first line contains two integers N and T, where N is the number of elements in the array and T is the threshold.
  2. The second line contains N space-separated integers representing the array A.

outputFormat

Output a single integer which is the smallest divisor d such that:

\(\sum_{i=1}^{N} \lceil \frac{A_i}{d} \rceil \leq T\)

## sample
4 6
1 2 5 9
5

</p>