#C5242. Candy Distribution Problem
Candy Distribution Problem
Candy Distribution Problem
You are given the task of distributing candies among employees such that each employee receives an equal number of candies with no leftover distribution from the total candy supply.
You are provided with two integers: \( k \), the number of employees, and \( b \), the number of candy batches. The next line contains \( b \) integers where the \( i^{th} \) integer represents the number of candies in the \( i^{th} \) batch.
The goal is to determine the maximum number \( x \) such that each employee can receive \( x \) candies when all batches of candies are combined and distributed evenly. The answer is given by the formula:
\( x = \left\lfloor \frac{\sum_{i=1}^{b} a_i}{k} \right\rfloor \)
where \( a_i \) is the candy count of the \( i^{th} \) batch. Note that \( \lfloor \cdot \rfloor \) represents the floor division.
inputFormat
The input is read from standard input. The first line contains two integers ( k ) and ( b ) separated by a space. The second line contains ( b ) space-separated integers representing the number of candies in each batch.
outputFormat
Output a single integer on standard output which is the maximum number of candies each employee can receive with no leftovers.## sample
5 4
10 20 25 30
17
</p>