#include <bits/stdc++.h>
const int N = 5005, M = 10005;
int n, m, sum, now;
int dp[2][M], a[N], f[N][M], Ans[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    sum = 0, now = 0;
    memset(dp, 0x3f, sizeof(dp));
    dp[now][0] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      now = now ^ 1;
      for (int j = 0; j <= sum / 10; j++) dp[now][j] = 0x3f3f3f3f;
      for (int j = 0; j <= sum / 10; j++) {
        int rest = m - (sum - dp[now ^ 1][j]) + j;
        for (int k = 0; k <= std::min(a[i] / 2, rest); k++) {
          int cst = a[i] - k;
          if (dp[now ^ 1][j] + cst < dp[now][j + cst / 10]) {
            dp[now][j + cst / 10] = dp[now ^ 1][j] + cst;
            f[i][j + cst / 10] = k;
          }
        }
      }
      sum += a[i];
    }
    int ans = sum, tot;
    for (int i = 0; i <= sum / 10; i++)
      if (dp[now][i] < ans) ans = dp[now][i], tot = i;
    printf("%d\n", ans);
    for (int i = n; i >= 1; i--)
      Ans[i] = f[i][tot], tot -= (a[i] - f[i][tot]) / 10;
    for (int i = 1; i <= n; i++) printf("%d%c", Ans[i], (i == n ? '\n' : ' '));
  }
}
