#K47792. Minimize Maximum Water Distribution
Minimize Maximum Water Distribution
Minimize Maximum Water Distribution
You are given n friends and a list of integers representing the amount of water each friend initially carries. The friends decide to redistribute the water among themselves such that the water is as evenly distributed as possible. Your task is to compute the minimum possible maximum amount of water any friend will have to carry after the redistribution.
Mathematically, if the total amount of water is \(W\) and there are \(n\) friends, then the answer is given by the formula:
\(\lceil \frac{W}{n} \rceil\)
where \(\lceil x \rceil\) denotes the ceiling of \(x\).
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains a single integer n (1 ≤ n ≤ 105) representing the number of friends.
- The second line contains n space-separated integers where each integer denotes the amount of water that each friend initially carries. Each water amount is non-negative and does not exceed 109.
outputFormat
Output a single integer representing the minimum possible maximum amount of water any friend will have after redistribution. The result is the ceiling of the average of total water.
## sample3
5 8 7
7