Logo
(追記) (追記ここまで)

31643번 - Milk Exchange 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB58464583.333%

문제

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

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

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

입력

The first line contains $N$.

The next line contains integers $a_1,a_2,...,a_N$.

출력

Output $N$ lines, where the $i$-th line is the total milk left among all cows after $i$ minutes.

제한

예제 입력 1

6
2 2 2 1 2 1

예제 출력 1

8
7
6
6
6
6

Initially, the amount of milk in each bucket is $[2, 2, 2, 1, 2, 1]$.

  • After 1ドル$ minute, the amount of milk in each bucket is $[1, 2, 2, 1, 1, 1]$ so the total amount of milk is 8ドル$.
  • After 2ドル$ minutes, the amount of milk in each bucket is $[1, 1, 2, 1, 1, 1]$ so the total amount of milk is 7ドル$.
  • After 3ドル$ minutes, the amount of milk in each bucket is $[1, 1, 1, 1, 1, 1]$ so the total amount of milk is 6ドル$.
  • After 4ドル$ minutes, the amount of milk in each bucket is $[1, 1, 1, 1, 1, 1]$ so the total amount of milk is 6ドル$.
  • After 5ドル$ minutes, the amount of milk in each bucket is $[1, 1, 1, 1, 1, 1]$ so the total amount of milk is 6ドル$.
  • After 6ドル$ minutes, the amount of milk in each bucket is $[1, 1, 1, 1, 1, 1]$ so the total amount of milk is 6ドル$.

예제 입력 2

8
3 8 6 4 8 3 8 1

예제 출력 2

25
20
17
14
12
10
8
8

After 1ドル$ minute, the amount of milk in each bucket is $[1, 3, 6, 4, 4, 3, 3, 1]$ so the total amount of milk is 25ドル$.

예제 입력 3

10
9 9 10 10 6 8 2 1000000000 1000000000 1000000000

예제 출력 3

2000000053
1000000054
56
49
42
35
28
24
20
20

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 February Contest > Gold 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /