Halloween Candles
Limits: 2 sec., 256 MiB
Kids in a village are preparing candles and pumpkins for a Halloween night. They have \(\mathbf{N}\) pumpkins and would like to put exactly one candle inside each of them.
The kids have \(\mathbf{M}\) candles of different length. They would like to have \(\mathbf{N}\) candles of the same length to use with the pumpkins. In order to achieve the goal the kids can arbitrary cut the candles they have. A single candle can be cut into multiple smaller ones with sum of their lengths equal to the initial candle length. However, it is impossible to connect multiple candles in order to get a longer one.
The kinds want \(\mathbf{N}\) candles inside pumpkins to be as long as possible. Your task is to find the maximal possible candle length inside each of the pumpkins. Note that they don’t necessarily have to use all \(\mathbf{M}\) candles.
Input
The first line contains two integers \(\mathbf{N}\) and \(\mathbf{M}\) separated by a single space.
The second line contains \(\mathbf{M}\) integers (candle lengths) separated by single spaces \(\mathbf{L_1}, \ldots, \mathbf{L_M}\).
Output
Print a maximal possible length of a candle inside a pumpkin.
An answer will be considered correct if its absolute or relative error does not exceed \(10^{-7}\).
Constraints
\(1 \leq \mathbf{N}, \mathbf{M} \leq 100\),
\(1 \leq \mathbf{L_j} \leq 100\).
Samples
Input (stdin) | Output (stdout) |
---|---|
4 3 1 4 2 | 1.33333333 |
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|