#include <bits/stdc++.h>
int N, B, a[5000], X[5001][12], Y[5001][12], SA;
inline int min(int x, int y) { return x < y ? x : y; }
inline int floordiv(int x, int y) { return x < 0 ? (x - y + 1) / y : x / y; }
int GPOS(int x, int y) {
  if (y < X[x][11] || y < 0) return Y[x][0];
  int d = 1;
  while (X[x][d] > y) d++;
  return Y[x][d] + floordiv(y - X[x][d], d);
}
int DP(int x, int y) {
  int res = 1000000000;
  for (int i = 0; i <= y && i + i <= a[x]; i++)
    res = min(res, GPOS(x + 1, y - i + (a[x] - i) / 10) - (a[x] - i) / 10);
  return res;
}
int main() {
  scanf("%d%d", &N, &B);
  for (int i = 0; i < N; i++) {
    scanf("%d", a + i);
    SA += a[i];
  }
  for (int i = N - 1; ~i; i--) {
    Y[i][0] = DP(i, 0);
    int l = 0, r = 1000000000;
    while (l < r) {
      int m = l + r >> 1;
      if (DP(i, m) > Y[i][0])
        r = m;
      else
        l = m + 1;
    }
    X[i][11] = l - 11, Y[i][11] = Y[i][0];
    for (int j = 10; j; j--) {
      int STX = X[i][j + 1], STY = Y[i][j + 1], l = 0,
          r = (1000000000 - STX) / (j + 1);
      while (l < r) {
        int m = l + r + 1 >> 1;
        if (DP(i, STX + m * (j + 1) - 1) == STY + m - 1)
          l = m;
        else
          r = m - 1;
      }
      X[i][j] = STX + l * (j + 1), Y[i][j] = Y[i][j + 1] + l;
    }
  }
  printf("%d\n", SA + GPOS(0, B) - B);
  for (int i = 0, j = B, r; i < N; j = j - r + (a[i++] - r) / 10) {
    r = 0;
    int thisDP = GPOS(i, j);
    while (thisDP != GPOS(i + 1, j - r + (a[i] - r) / 10) - (a[i] - r) / 10)
      r++;
    printf("%d ", r);
  }
  puts("");
  return 0;
}
