#include <bits/stdc++.h>
const int inf = 1000000000, m = 10000;
int p[5005][10005], f[10005], g[10005], a[5005], sum[5005], use[5005], n, B;
int main() {
  scanf("%d%d\n", &n, &B);
  for (int i = 1; i <= m; i++) f[i] = g[i] = inf;
  int cur = 0;
  g[0] = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    sum[i] = sum[i - 1] + x;
    cur = std::min(cur + x / 10, m);
    for (int j = 0; j <= cur; j++) f[j] = g[j], g[j] = inf;
    for (int j = 0; j <= cur; j++)
      if (f[j] <= sum[i - 1]) {
        int b = B - sum[i - 1] + f[j] + j;
        for (int k = 0; k <= x / 2 && k <= b; k++) {
          int y = j + (x - k) / 10;
          if (f[j] + x - k < g[y]) {
            g[y] = f[j] + x - k;
            p[i][y] = k;
          }
        }
      }
  }
  int ans = 0;
  for (int i = 1; i <= cur; i++)
    if (g[i] < g[ans]) ans = i;
  printf("%d\n", g[ans]);
  for (int i = n; i >= 1; ans -= (a[i] - p[i][ans]) / 10, i--)
    use[i] = p[i][ans];
  for (int i = 1; i <= n; i++) printf("%d ", use[i]);
}
