#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int dp[2][maxn];
int a[maxn];
const int inf = 1000000000;
int pre[5006][maxn];
int con[maxn];
int main() {
  int n, b;
  int u = 0;
  cin >> n >> b;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < (maxn); i++) dp[0][i] = dp[1][i] = inf;
  dp[0][0] = 0;
  int all = 0;
  for (int i = 1; i <= n; i++) {
    u = u ^ 1;
    for (int j = 0; j < maxn; j++) {
      if (dp[u ^ 1][j] != inf) {
        int rest = -(all - dp[u ^ 1][j]) + b + j;
        for (int f = 0; f <= min(rest, a[i] / 2); f++) {
          if (dp[u][j + (a[i] - f) / 10] > dp[u ^ 1][j] + a[i] - f) {
            dp[u][j + (a[i] - f) / 10] = dp[u ^ 1][j] + a[i] - f;
            pre[i][j + (a[i] - f) / 10] = f;
          }
        }
      }
    }
    for (int j = 0; j < maxn; j++) {
      dp[u ^ 1][j] = inf;
    }
    all += a[i];
  }
  int ans = inf;
  int rest = 0;
  for (int i = 0; i < maxn; i++) {
    if (ans > dp[u][i]) {
      ans = dp[u][i];
      rest = i;
    }
  }
  printf("%d\n", ans);
  for (int i = n; i >= 1; i--) {
    con[i] = pre[i][rest];
    rest = rest - (a[i] - pre[i][rest]) / 10;
  }
  for (int i = 1; i <= n; i++) printf("%d ", con[i]);
}
