//这题也是水题 #include <bits/stdc++.h> using namespace std; const int N = 505; int planned[N]; int total[N]; int main() { int n, k; while (cin >> n >> k) { int ans = 0; // sum of additional hours for (int i = 0; i < n; i++) { cin >> planned[i]; total[i] = planned[i]; } for (int i = 0; i < (n - 1); i++) { int sum = total[i] + total[i + 1], temp; if (k > sum) { temp = k - sum; ans += temp; total[i + 1] += temp; } } cout << ans << endl; for(int i = 0; i < (n - 1); i++) cout << total[i] << " "; cout << total[n -1] << endl; } return 0; }