#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
int data[maxn];
int main() {
  int n, h;
  while (cin >> n >> h) {
    vector<pair<int, int> > vc;
    for (int i = 0; i < n; ++i) {
      scanf("%d", data + i);
      vc.push_back(make_pair(data[i], i));
    }
    sort(vc.begin(), vc.end());
    int ans = vc[(int)vc.size() - 1].first + vc[(int)vc.size() - 2].first -
              vc[0].first - vc[1].first;
    int mi = vc[0].first + h + vc[1].first;
    if ((int)vc.size() > 2) mi = min(mi, vc[1].first + vc[2].first);
    int ma = vc[0].first + h + vc[(int)vc.size() - 1].first;
    if ((int)vc.size() > 2)
      ma = max(ma, vc[(int)vc.size() - 1].first + vc[(int)vc.size() - 2].first);
    if (ans < ma - mi) {
      for (int i = 0; i < n; ++i) {
        data[vc[i].second] = 1;
      }
    } else {
      ans = ma - mi;
      for (int i = 0; i < n; ++i) {
        data[vc[i].second] = 2;
      }
      data[vc[0].second] = 1;
    }
    cout << ans << endl;
    for (int i = 0; i < n; ++i) {
      printf("%d%c", data[i], (i == n - 1) ? '\n' : ' ');
    }
  }
  return 0;
}
