RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0610

Milk Exchange

Gold II 골드 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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, 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?

Problem credits: Chongtian Ma, Alex Liang, Patrick Deng

제약

SCORING

  • Inputs 4-5: \(N \le 2000\)
  • Inputs 6-8: \(a_i \le 2\)
  • Inputs 9-13: All \(a_i\) are generated uniformly at random in the range \([1,10^9]\).
  • Inputs 14-23: No additional constraints.

Problem credits: Chongtian Ma, Alex Liang, Patrick Deng

입력 형식

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
출력
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
출력
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
출력
2000000053
1000000054
56
49
42
35
28
24
20
20
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > February > Gold

태그

평가 및 의견

Milk Exchange

개요
출제자 난이도 Gold II 골드 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Milk Exchange

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8