#C5245. Redistribute Marbles
Redistribute Marbles
Redistribute Marbles
You are given N boxes, each containing some number of marbles. The number of marbles in the ith box is given by Ai.
You are allowed to redistribute the marbles arbitrarily among the boxes. Your goal is to maximize the number of marbles in each box so that every box has the same number of marbles. The final answer is computed by taking the floor of the total number of marbles divided by N, which can be mathematically expressed as:
$$\text{result} = \left\lfloor \frac{\sum_{i=1}^{N} A_i}{N} \right\rfloor$$
Print the maximum number of marbles that can be left in each box after an optimal redistribution.
inputFormat
The input is read from stdin
with the following format:
- The first line contains an integer
N
representing the number of boxes. - The second line contains
N
space-separated integers where the ith integer represents the number of marbles in the ith box.
outputFormat
Output to stdout
a single integer representing the maximum number of marbles that can be placed in each box after redistribution.
3
6 8 10
8
</p>