#5024. Problem 2. Milk Exchange
Problem 2. Milk Exchange
Problem 2. Milk Exchange
USACO 2024 February Contest, Gold
Farmer John's cows are lined up in a circle. The th cow has a bucket with integer capacity liters. All buckets are initially full.
Every minute, cow will pass all the milk in their bucket to cow for , with cow passing its milk to cow . All exchanges happen simultaneously (i.e., if a cow has a full bucket but gives away liters of milk and also receives liters, her milk is preserved). If a cow's total milk ever ends up exceeding , then the excess milk will be lost.
After each of minutes, how much total milk is left among all cows?
INPUT FORMAT (input arrives from the terminal / stdin):
The first line contains .
The next line contains integers .
OUTPUT FORMAT (print output to the terminal / stdout):
Output lines, where the -th line is the total milk left among all cows after minutes.
SAMPLE INPUT:
6 2 2 2 1 2 1
SAMPLE OUTPUT:
8 7 6 6 6 6
Initially, the amount of milk in each bucket is .
- After minute, the amount of milk in each bucket is so the total amount of milk is .
- After minutes, the amount of milk in each bucket is so the total amount of milk is .
- After minutes, the amount of milk in each bucket is so the total amount of milk is .
- After minutes, the amount of milk in each bucket is so the total amount of milk is .
- After minutes, the amount of milk in each bucket is so the total amount of milk is .
- After minutes, the amount of milk in each bucket is so the total amount of milk is .
SAMPLE INPUT:
8 3 8 6 4 8 3 8 1
SAMPLE OUTPUT:
25 20 17 14 12 10 8 8
After minute, the amount of milk in each bucket is so the total amount of milk is .
SAMPLE INPUT:
10 9 9 10 10 6 8 2 1000000000 1000000000 1000000000
SAMPLE OUTPUT:
2000000053 1000000054 56 49 42 35 28 24 20 20
SCORING: Inputs 4-5: Inputs 6-8: Inputs 9-13: All are generated uniformly at random in the range . Inputs 14-23: No additional constraints.
Problem credits: Chongtian Ma, Alex Liang, Patrick Deng