PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000308. Ăn táo trên vòng tròn (Apple Baskets on Circle)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ăn táo trên vòng tròn (Apple Baskets on Circle)
Apple Baskets on Circle
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are n baskets in a circle, numbered 1 through n, with apples in basket i. Starting at basket 1, eat one apple if the current basket is nonempty, then move to the next basket, wrapping around after n. Stop upon eating exactly k apples. Find the remaining counts.
Input
First line: n,k. Second line: n integers .
Output
Print n integers in original basket order.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input 1
3 3
1 3 0
Output 1
0 1 0
Explanation
The first lap removes apples from baskets 1 and 2. The next lap removes one from basket 2 and stops.
Input 2
4 6
3 0 4 3
Output 2
1 0 2 1
Explanation
Two complete laps remove three apples per lap.