#include <bits/stdc++.h>
using namespace std;
const int Maxn = 5050, Maxstate = 10020, Inf = 1e9;
int n, b;
int a[Maxn], sum[Maxn];
int dp[2][10020];
short pre[Maxn][Maxstate];
void init(int cs) {
  for (int i = 0; i < Maxstate; i++) dp[cs][i] = Inf;
}
int main() {
  scanf("%d%d", &n, &b);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), sum[i] = sum[i - 1] + a[i];
  int cs = 0;
  init(0);
  init(1);
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++, cs ^= 1) {
    init(cs ^ 1);
    for (int j = 0; j < Maxstate; j++) {
      if (dp[cs][j] == Inf) continue;
      int w = dp[cs][j];
      int total = sum[i - 1];
      int rest = b + j - (total - w);
      for (int k = 0; k <= rest && k <= a[i] / 2; k++) {
        int nw = w + a[i] - k;
        int nj = j + (a[i] - k) / 10;
        if (dp[cs ^ 1][nj] > nw) {
          dp[cs ^ 1][nj] = nw;
          pre[i][nj] = a[i] - k;
        }
      }
    }
  }
  int ans = Inf, cur = -1;
  for (int i = 0; i < Maxstate; i++)
    if (dp[cs][i] < ans) {
      cur = i;
      ans = dp[cs][i];
    }
  printf("%d\n", ans);
  vector<int> rep;
  for (int i = n; i > 0; i--) {
    rep.push_back(pre[i][cur]);
    cur = cur - pre[i][cur] / 10;
  }
  reverse(rep.begin(), rep.end());
  for (int i = 0; i < rep.size(); i++)
    printf("%d%c", a[i + 1] - rep[i], i == rep.size() - 1 ? '\n' : ' ');
  return 0;
}
