#BS0000132. Thử trà (Tea Tasting)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Thử trà (Tea Tasting)
Tea Tasting
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are tea varieties and tasters, both numbered from to . Variety initially has milliliters. Taster can drink up to milliliters per step. Initially taster drinks from variety . After each step every active taster moves to the previous variety; anyone past variety 1 leaves. Each drink is the minimum of the remaining quantity and that taster's capacity. Compute the total amount drunk by each taster over all steps.
Input
The first line contains . The second line has ; the third has .
Output
Print integers in taster order, giving the total milliliters consumed by each taster.
Subtasks
- Subtask 1 (20 points): ; , .
- Subtask 2 (30 points): ; , .
- Subtask 3 (50 points): ; , .
Examples
Input
3
10 20 15
9 8 6
Output
9 9 12
Explanation
Step 1: tasters drink , leaving tea quantities . Step 2: taster 1 has left, taster 2 drinks from variety 1, and taster 3 drinks from variety 2; totals are now and tea is . Step 3: taster 3 reaches empty variety 1, drinking nothing. Print 9 9 12.