Milk Exchange
시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2024 February GoldBOJ 31643
문제
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?
입력
The first line contains .The next line contains integers .
출력
Output lines, where the -th line is the total milk left among all cows after minutes.예제
예제 1
입력
6 2 2 2 1 2 1
출력
8 7 6 6 6 6
예제 2
입력
8 3 8 6 4 8 3 8 1
출력
25 20 17 14 12 10 8 8
예제 3
입력
10 9 9 10 10 6 8 2 1000000000 1000000000 1000000000
출력
2000000053 1000000054 56 49 42 35 28 24 20 20
코드를 제출하려면 로그인하세요.