点击打开链接
B. Cormen — The Best Friend Of a Man
time limit per test
memory limit per test
input
output
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk.
k walks for any two consecutive days in order to feel good. For example, if k = 5and yesterday Polycarp went for a walk with Cormen 2 times, today he has to go for a walk at least 3
n days and made a sequence of n integers a1, a2, ..., an, where ai is the number of times Polycarp will walk with the dog on the i-th day while doing all his affairs (for example, he has to go to a shop, throw out the trash, etc.).
n days so that Cormen will feel good during all the n days. You can assume that on the day before the first day and on the day after the n-th day Polycarp will go for a walk with Cormen exactly k
b1, b2, ..., bn (bi ≥ ai), where bi means the total number of walks with the dog on the i-th day.
Input
n and k (1 ≤ n, k ≤ 500) — the number of days and the minimum number of walks with Cormen for any two consecutive days.
a1, a2, ..., an (0 ≤ ai) — the number of walks with Cormen on the i-th day which Polycarp has already planned.
Output
n
n integers b1, b2, ..., bn, where bi — the total number of walks on the i-th day according to the found solutions (ai ≤ bi for all i from 1 to n). If there are multiple solutions, print any of them.
Examples
input
3 5 2 0 1
output
4 2 3 2
input
3 1 0 0 0
output
1 0 1 0
input
4 6 2 4 3 5
output
0 2 4 3 5
题意:最近的两个的和要大于或者等于k,不够的补充,输出补充的数的和,和改变之后的数。参考了别人的想法。