#K64317. Water Redistribution Problem
Water Redistribution Problem
Water Redistribution Problem
In a small village, every villager has a container with some water. The village chief has decided to redistribute the water equally among all villagers. Any water that cannot be evenly divided is poured into a communal reservoir and is not used by the villagers.
You are given an integer N representing the number of villagers, followed by N non-negative integers which indicate the amount of water in each container. Your task is to modify the water distribution so that every villager ends up with \(\left\lfloor \frac{total\ water}{N} \right\rfloor\) units of water, where the total water is the sum of water in all containers.
Input format: The first line contains an integer N. The second line contains N space-separated non-negative integers.
Output format: Output a single line with N space-separated integers representing the new water amount in each container after the redistribution.
inputFormat
The first line of input is a single integer N (1 ≤ N ≤ 105), indicating the number of villagers. The second line contains N space-separated non-negative integers, where each integer represents the amount of water in a villager's container. The sum of all water amounts fits in a 32-bit signed integer.
outputFormat
Output a single line containing N space-separated integers. Each integer is the redistributed water amount (which is equal for all villagers) calculated as the floor of (total water / N).
## sample3
3 5 9
5 5 5
</p>