#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4 + 5;
const int MAXN = 5000 + 5;
const int INF = 1e9;
short par[MAXN][MAX];
int a[MAXN], sum[MAXN];
int dp[2][MAX];
int main() {
  int n, b;
  cin >> n >> b;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  int cur = 0;
  for (int i = 0; i < MAX; i++) dp[0][i] = dp[1][i] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < MAX; j++) dp[1 - cur][j] = INF;
    for (int j = 0; j < MAX; j++) {
      if (dp[cur][j] == INF) continue;
      int cost = dp[cur][j];
      int s = sum[i - 1];
      int have = b + j - (s - cost);
      for (int k = 0; k <= min(a[i] / 2, have); k++) {
        int newCost = cost + a[i] - k;
        int newCreate = j + (a[i] - k) / 10;
        if (dp[1 - cur][newCreate] > newCost) {
          dp[1 - cur][newCreate] = newCost;
          par[i][newCreate] = a[i] - k;
        }
      }
    }
    cur = 1 - cur;
  }
  int ans = INF, create = -1;
  for (int i = 0; i < MAX; i++)
    if (dp[cur][i] < ans) {
      create = i;
      ans = dp[cur][i];
    }
  cout << ans << endl;
  vector<int> ans2;
  int i = n;
  while (i > 0) {
    ans2.push_back(par[i][create]);
    create = create - par[i][create] / 10;
    i--;
  }
  reverse(ans2.begin(), ans2.end());
  for (int i = 1; i <= ans2.size(); i++) cout << a[i] - ans2[i - 1] << " ";
  cout << endl;
  return 0;
}
