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

Bài tập thuộc lộ trình

1 lộ trình

Ă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 aia_i 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 aia_i.

Output

Print n integers in original basket order.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le30; 1≤k≤1001\le k\le100; 0≤ai≤1000\le a_i\le100; ∑ai≥k\sum a_i\ge k.
  • Subtask 2 (30 points): 1≤n≤1051\le n\le10^5; 1≤k≤10121\le k\le10^{12}; 0≤ai≤10120\le a_i\le10^{12}; ∑ai≥k\sum a_i\ge k; a1=⋯=ana_1=\cdots=a_n.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 1≤k≤10121\le k\le10^{12}; 0≤ai≤10120\le a_i\le10^{12}; ∑ai≥k\sum a_i\ge k.

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.