#include <bits/stdc++.h>
using namespace std;
const int N = 5005, M = 10005;
int last[N][M], f[2][M], n, m, a[N], ans[N], size, b[N], T;
int main() {
  scanf("%d%d", &n, &m);
  memset(f, 0x3f, sizeof f);
  f[0][0] = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[i];
    T ^= 1;
    memset(f[T], 0x3f, sizeof f[T]);
    for (int j = 0; j <= size; j++)
      if (f[!T][j] <= b[i - 1]) {
        int now = m + f[!T][j] + j - b[i - 1];
        for (int k = 0; k <= a[i] / 2 && k <= now; k++) {
          int nj = j + (a[i] - k) / 10;
          if (f[!T][j] + a[i] - k < f[T][nj])
            last[i][nj] = k, f[T][nj] = f[!T][j] + a[i] - k;
        }
      }
    size += a[i] / 10;
  }
  int now = 0;
  for (int i = 1; i <= size; i++)
    if (f[T][i] < f[T][now]) now = i;
  printf("%d\n", f[T][now]);
  for (int i = n; i; i--) ans[i] = last[i][now], now -= (a[i] - ans[i]) / 10;
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
