#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
struct node {
  int v, no, ans;
} a[N];
int n;
bool cmp2(node a, node b) { return a.v < b.v; };
bool cmp(node a, node b) { return a.no < b.no; };
int main() {
  int h;
  cin >> n >> h;
  for (int i = 0; i < n; i++) cin >> a[i].v, a[i].no = i;
  sort(a, a + n, cmp2);
  int ans = a[n - 1].v + a[n - 2].v - a[1].v - a[0].v;
  int i = 0;
  int he = a[n - 1].v + a[n - 2].v;
  if (n > 2)
    while (1) {
      int hs;
      if (i) {
        hs = a[0].v + a[1].v;
      } else
        hs = min(a[i].v + a[i + 1].v + h, a[i + 1].v + a[i + 2].v);
      int ht = a[i].v + a[n - 1].v + h;
      he = max(he, ht);
      if (he - hs < ans) {
        ans = he - hs;
        i++;
      } else
        break;
    }
  cout << ans << endl;
  for (int j = 0; j < i; j++) a[j].ans = 1;
  for (int j = i; j < n; j++) a[j].ans = 2;
  sort(a, a + n, cmp);
  for (int i = 0; i < n; i++) cout << a[i].ans << " ";
  return 0;
}
