#P7585. [COCI 2012/2013 #1] LJUBOMORA

[COCI 2012/2013 #1] LJUBOMORA

Description

A marble factory donated some marbles to a kindergarten. There are MM different colors of marbles, and each marble has exactly one color. The teacher needs to distribute all the marbles to NN children. All marbles given to the same child must be of the same color, and some children may receive no marbles at all.

We define the jealousy value as the maximum number of marbles given to any single child. Please help the teacher distribute the marbles so that the jealousy value is as small as possible.

For example, if there are 44 red marbles (RRRR\texttt{RRRR}) and 77 blue marbles (BBBBBBB\texttt{BBBBBBB}), to be distributed among 55 children, we can distribute them as: RR\texttt{RR}, RR\texttt{RR}, BB\texttt{BB}, BB\texttt{BB}, BBB\texttt{BBB}. The jealousy value is then 33, and this is the minimum possible.

Input Format

The input has M+1M+1 lines.

The first line contains two positive integers N,MN, M, representing the number of children and the total number of colors of marbles.

In the next MM lines, the ii-th line contains a positive integer xx (x[1,109]x \in [1,10^9]), meaning there are xx marbles of color ii.

Output Format

Output one line with one integer, representing the minimum jealousy value.

5 2
7
4
3
7 5
7
1
7
4
4
4

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that 1M3×1051 \le M \le 3 \times 10^5, 1N1091 \le N \le 10^9, and MNM \le N.

Notes

The score of this problem follows the original COCI settings, with a full score of 120120.

Translated from COCI2012-2013 CONTEST #1 T4 LJUBOMORA.

Translated by ChatGPT 5