#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,a[505];
cin>>n>>k;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
int rest;
int sum=0;
for(int i=2;i<=n;i++)
{
if(a[i]+a[i-1]>=k)
{
continue;
}
else
{
rest=k-(a[i]+a[i-1]);
a[i]+=rest;
sum+=rest;
}
}
printf("%d\n",sum);
for(int i=1;i<=n;i++)
{
printf("%d ",a[i]);
}
return 0;
}
codeforces 732B Cormen — The Best Friend Of a Man (水题)
最新推荐文章于 2018-08-09 23:00:14 发布