#667
Unrated
Milk Exchange
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John's NN (1N5105)(1 \leq N \leq 5 \cdot 10^5) cows are lined up in a circle. The iith cow has a bucket with integer capacity aia_i (1ai109)(1 \leq a_i \leq 10^9) liters. All buckets are initially full.

Every minute, cow ii will pass all the milk in their bucket to cow i+1i+1 for 1i<N1\le i<N, with cow NN passing its milk to cow 11. All exchanges happen simultaneously (i.e., if a cow has a full bucket but gives away xx liters of milk and also receives xx liters, her milk is preserved). If a cow's total milk ever ends up exceeding aia_i, then the excess milk will be lost.

After each of 1,2,,N1, 2, \dots, N minutes, how much total milk is left among all cows?

입력

The first line contains NN.

The next line contains integers a1,a2,...,aNa_1,a_2,...,a_N.

출력

Output NN lines, where the ii-th line is the total milk left among all cows after ii minutes.

예제 입력 1

6
2 2 2 1 2 1

예제 출력 1

8
7
6
6
6
6

예제 입력 2

8
3 8 6 4 8 3 8 1

예제 출력 2

25
20
17
14
12
10
8
8

예제 입력 3

10
9 9 10 10 6 8 2 1000000000 1000000000 1000000000

예제 출력 3

2000000053
1000000054
56
49
42
35
28
24
20
20

점수

Inputs 4-5: N2000N \le 2000Inputs 6-8: ai2a_i \le 2Inputs 9-13: All aia_i are generated uniformly at random in the range [1,109][1,10^9]. Inputs 14-23: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.