#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream& operator<<(ostream& cout, pair<L, R> P) {
  return cout << '(' << P.first << ',' << P.second << ')';
}
template <class T>
ostream& operator<<(ostream& cout, vector<T> V) {
  cout << "[ ";
  for (auto v : V) cout << v << ' ';
  return cout << ']';
}
std::vector<long long> inp;
bool cmp(long long a, long long b) { return inp[a] < inp[b]; }
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, h;
  cin >> n >> h;
  inp.resize(n);
  vector<long long> vec(n);
  iota(vec.begin(), vec.end(), 0);
  for (long long i = 0; i < n; ++i) {
    cin >> inp[i];
  }
  sort(vec.begin(), vec.end(), cmp);
  sort(inp.begin(), inp.end());
  if (inp.size() == 2) {
    cout << 0 << "\n1 1";
    return 0;
  }
  long long ans = inp[n - 1] + inp[n - 2] - (inp[0] + inp[1]);
  pair<long long, long long> pr = {1, -1};
  for (long long i = 1; i < n - 1; ++i) {
    long long maxi = 0;
    if (i < n - 2) {
      maxi = inp[n - 1] + inp[n - 2];
    }
    maxi = max(inp[i] + inp[n - 1] + h, maxi);
    long long mini = (inp[0] + inp[1] + h);
    if (i + 1 < n) {
      mini = min(inp[0] + inp[i + 1], mini);
    }
    if (i >= 2) {
      mini = min(mini, inp[1] + inp[2]);
    }
    if ((maxi - mini) < ans) {
      ans = maxi - mini;
      pr.second = i;
    }
  }
  long long maxi = max(inp[n - 1] + inp[n - 1], inp[0] + inp[n - 1] + h);
  long long mini = min(inp[0] + inp[1] + h, inp[1] + inp[2]);
  if ((maxi - mini) < ans) {
    ans = maxi - mini;
    pr.second = n - 1;
  }
  maxi = max(inp[n - 1] + inp[n - 2], inp[0] + inp[n - 1] + h);
  mini = min(inp[0] + inp[1] + h, inp[1] + inp[2]);
  if ((maxi - mini) < ans) {
    ans = maxi - mini;
    pr.first = 0;
  }
  if (pr.first == 0) {
    cout << ans << "\n";
    vector<long long> fin(n, 0);
    fin[vec[0]] = 1;
    for (long long i = 0; i < n; ++i) {
      cout << fin[i] + 1 << " ";
    }
    return 0;
  }
  cout << ans << "\n";
  if (pr.second == -1) {
    for (auto it : inp) {
      cout << 1 << " ";
    }
    return 0;
  }
  vector<long long> fin(n);
  fin[vec[0]] = 1;
  for (long long i = 1; i <= pr.second; ++i) {
    fin[vec[i]] = 2;
  }
  for (long long i = pr.second + 1; i < n; ++i) {
    fin[vec[i]] = 1;
  }
  for (long long i = 0; i < n; ++i) {
    cout << fin[i] << ' ';
  }
}
