#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-5;
const long double PI = acos(-1);
const int INF = (int)1e9;
const long long INFF = (long long)1e18;
const int mod = (int)1e9 + 7;
const int MXN = (int)1e4 + 7;
int a[MXN];
int lsum[MXN];
int dp[2][MXN];
int re[5007][MXN];
int bst[MXN];
int main(void) {
  int n, b;
  scanf("%d %d", &n, &b);
  for (int i = 1; i < n + 1; ++i) scanf("%d", a + i);
  for (int i = 1; i < n + 1; ++i) lsum[i] = lsum[i - 1] + a[i];
  for (int i = 0; i < MXN; ++i) dp[0][i] = INF;
  dp[0][0] = 0;
  int p1 = 0, p2 = 1;
  for (int i = 1; i <= n; ++i, swap(p1, p2)) {
    for (int j = 0; j < MXN; ++j) dp[p2][j] = INF;
    for (int j = 0; j < MXN; ++j) {
      if (dp[p1][j] == INF) continue;
      int la = b + j - (lsum[i - 1] - dp[p1][j]);
      for (int k = 0; k < a[i] / 2 + 1; ++k) {
        if (k > la) break;
        int v = dp[p1][j] + (a[i] - k);
        int nxt = j + (a[i] - k) / 10;
        if (dp[p2][nxt] > v) {
          dp[p2][nxt] = v;
          re[i][nxt] = k;
        }
      }
    }
  }
  int ans = INF, pos = 0;
  for (int i = 0; i < MXN; ++i) {
    if (dp[p1][i] < ans) {
      ans = dp[p1][i];
      pos = i;
    }
  }
  printf("%d\n", ans);
  for (int i = n; i >= 1; --i) {
    bst[i] = re[i][pos];
    pos = pos - (a[i] - re[i][pos]) / 10;
  }
  for (int i = 1; i < n + 1; ++i) printf("%d%c", bst[i], " \n"[i == n]);
  return 0;
}
