#abc208c. C - Fair Candy Distribution

C - Fair Candy Distribution

Score : 300300 points

问题描述

在高桥王国中有 NN 名公民。每位公民都有一个国家身份证号码;第 ii 位公民的身份证号码为 aia_i。这里,所有的 aia_i 都两两不同。

高桥有 KK 块糖果。他决定按照以下方式将这些糖果分发给公民,直到糖果分完为止。

  • 当他拥有不少于 NN 块糖果时,向每一位公民分发一块糖果。
  • 否则,设 KK' 为他当前拥有的糖果数量,并将一块糖果分发给身份证号码最小的 KK' 位公民。

当所有糖果都分发完毕后,第 ii 位公民将会获得多少块糖果?

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN citizens in the Kingdom of Takahashi. Each citizen has a national ID number; the ID of the ii-th citizen is aia_i. Here, all aia_i are pairwise different.

Takahashi has KK pieces of sweets. He has decided to hand out these pieces to the citizens in the following way until he has no more pieces.

  • When he has NN or more pieces, hand out one piece to every citizen.
  • Otherwise, let KK' be the number of pieces he has at the moment, and hand out one piece to each of the citizens with the KK' smallest IDs.

When all pieces are handed out, how many pieces will the ii-th citizen have?

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 1K10181 \leq K \leq 10^{18}
  • 1ai1091 \leq a_i \leq 10^9
  • All aia_i are pairwise different.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

a1a_1 a2a_2 \ldots aNa_N

Output

Print NN lines. The ii-th line should contain the number of pieces of sweets received by the ii-th citizen.

Sample Input 1

2 7
1 8

Sample Output 1

4
3

Takahashi will hand out the pieces as follows.

  • Hand out one piece to everyone, leaving Takhashi with 55 pieces.
  • Hand out one piece to everyone, leaving Takhashi with 33 pieces.
  • Hand out one piece to everyone, leaving Takhashi with 11 piece.
  • Hand out one piece to the 11-st citizen, leaving Takhashi with no pieces.

In the end, the 11-st citizen will receive 44 pieces, and the 22-nd citizen will receive 33 pieces.

Sample Input 2

1 3
33

Sample Output 2

3

Since there is just one citizen, Takahashi will hand out all pieces to that 11-st citizen.

Sample Input 3

7 1000000000000
99 8 2 4 43 5 3

Sample Output 3

142857142857
142857142857
142857142858
142857142857
142857142857
142857142857
142857142857

update @ 2024/3/10 09:21:45

}