AmazonOA #136
Distribute Packages
估计中等可在线判题
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.
输入格式
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 exactly n non-negative integers, any optimal final load distribution.
样例 1
输入:
2 3
1 2
输出:
3 3
样例 2
输入:
2 0
5 0
输出:
5 0
样例 3
输入:
3 2
0 0 0
输出:
1 1 0
样例说明
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.