cswork / OAOpen practice workspace

AmazonOA #136

Distribute Packages

Estimated MediumJudge-ready

Topics (AI-labelled)Binary SearchGreedy

Add all P indivisible packages to the existing n vehicles; a vehicle may receive 0, and original packages cannot be removed. Minimize the final maximum vehicle load. Output any optimal final load array; the distribution need not be unique.

Input

The first line contains n P, and the second line contains n original loads. The original gives no value bounds; this site sets 1≤n≤100000, 0≤P≤10^12, 0≤(original load)≤10^9.

Output

Output exactly n non-negative integers, any optimal final load distribution.

Example 1

Input:

2 3
1 2

Output:

3 3

Example 2

Input:

2 0
5 0

Output:

5 0

Example 3

Input:

3 2
0 0 0

Output:

1 1 0

Example notes

Example 1: you can output 3 3, adding 2 and 1, for 3 added in total; the maximum 3 is optimal. Example 2: nothing is added, so output 5 0. Example 3: you can output 1 1 0; putting 1 on any two different vehicles is also a correct answer.

Editorial

Loading solution…