#include <bits/stdc++.h>
using namespace std;
const int mn = 5005;
int n, b, sb;
int a[mn];
int d[2][10005];
short fa[5005][10005];
short used[5005][10005];
int sa[mn];
int main() {
  scanf("%d%d", &n, &b);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sa[i] = sa[i - 1] + a[i];
  bool p = 0;
  for (int i = 0; i < n; i++) {
    memset(d[p ^ 1], 1, sizeof d[p ^ 1]);
    for (int j = 0; j <= sb; j++) {
      if (d[p][j] > 1e7) continue;
      int nowb = b + j - (sa[i] - d[p][j]);
      int t = min({a[i + 1] / 2, nowb});
      for (int k = 0; k <= t; k++) {
        int v = j + (a[i + 1] - k) / 10;
        if (d[p ^ 1][v] > d[p][j] + a[i + 1] - k) {
          fa[i + 1][v] = j;
          used[i + 1][v] = k;
          d[p ^ 1][v] = d[p][j] + a[i + 1] - k;
        }
      }
    }
    sb += a[i + 1] / 10;
    p ^= 1;
  }
  int ans = 1e5 + 5, choose = 0;
  for (int j = 0; j <= sb; j++) {
    if (ans > d[p][j]) {
      ans = d[p][j];
      choose = j;
    }
  }
  printf("%d\n", ans);
  vector<int> v;
  for (int i = n; i; i--) {
    v.push_back(used[i][choose]);
    choose = fa[i][choose];
  }
  reverse(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    printf("%d ", v[i - 1]);
  }
  return 0;
}
