#include<cstdio>
#include<cstdlib>
#include<cstring>
typedef long long int64;
int a[100005],w[100005],ans[100005],m,max,min,n,i,h,k;
int comp(const void*i,const void*j){return a[*(int*)j]-a[*(int*)i];}
int main()
{
    scanf("%d%d",&n,&h);
    for (i=1;i<=n;i++)scanf("%d",&a[i]),w[i]=i;
    qsort(w+1,n,sizeof(int),comp);
    m=a[w[2]];max=a[w[1]]+a[w[2]];
    for (i=1;i<=n;i++)
      if (a[w[i]]+h<=m)break;
      else ans[w[i]]=1;
    if (i<=n)
    {
        min=a[w[n]]+a[w[n-1]]+h;
        if (min>a[w[n]]+a[w[n-2]])min=a[w[n]]+a[w[n-2]];
        for (k=2;i<=n;i++,k=3-k)ans[w[i]]=k;
        printf("%d\n",max-min);
    }
    else
    {
        min=a[w[n]]+a[w[n-1]];
        if (max-min>a[w[n]]+a[w[1]]+h-a[w[n-1]]-a[w[n-2]])
        max=a[w[n]]+a[w[1]]+h-a[w[n-1]]-a[w[n-2]],ans[w[n]]=2;
        else max-=min;
        printf("%d\n",max);
    }
    for (i=1;i<=n;i++)printf("%d ",ans[i]);
    return 0;
}


#include<cstdio>
#include<cstdlib>
#include<cstring>
typedef long long int64;
int a[100005],w[100005],ans[100005],m,max,min,n,i,h,k;
int comp(const void*i,const void*j)
{return a[*(int*)j]-a[*(int*)i];}
int main()
{
    scanf("%d%d",&n,&h);
    for (i=1;i<=n;i++)
      scanf("%d",&a[i]),w[i]=i;
    qsort(w+1,n,sizeof(int),comp);
    m=a[w[2]];max=a[w[1]]+a[w[2]];
    for (i=1;i<=n;i++)
      if (a[w[i]]+h<=m)break;
      else ans[w[i]]=1;
    if (i<=n)
    {
        min=a[w[n]]+a[w[n-1]]+h;
        for (k=2;i<=n;i++,k=3-k)ans[w[i]]=k;
        printf("%d\n",max-min);
    }
    else
    {
        min=a[w[n]]+a[w[n-1]];
        if (max-min>a[w[n]]+a[w[1]]+h-a[w[n-1]]-a[w[n-2]])
        max=a[w[n]]+a[w[1]]+h-a[w[n-1]]-a[w[n-2]],ans[w[n]]=2;
        else max-=min;
        printf("%d\n",max);
    }
    for (i=1;i<=n;i++)printf("%d ",ans[i]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(int argc, char const *argv[])
{
    int n, h, midx = 0, mi = 100000000;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(mi > a[i]) {
            a[i] = mi;
            midx = i;
        }
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 <= d2) {
        cout << d1 << endl;
        for (int i = 0; i < n; ++i)
        {
            if(i == midx)
                cout << 1 << " ";
            else
                cout << 2 << " ";
        }
    }
    else {
        cout << d2 << endl;
        for (int i = 0; i < n; ++i)
        {
            cout << 2 << " ";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
void printArr(int len) {
    for (int i = 0; i < len; ++i)
    {
        cout << 2 << " ";
    }
}
int main(int argc, char const *argv[])
{
    int n, h;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 < d2) {
        cout << d1 << endl;
        cout << "1 ";
        printArr(n - 1);
    }
    else {
        cout << d2 << endl;
        printArr(n);
        }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(int argc, char const *argv[])
{
    int n, h, midx = 0, mi = 100000000;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(mi > a[i]) {
            mi = a[i];
            midx = i;
        }
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 <= d2) {
        cout << d1 << endl;
        for (int i = 0; i < n; ++i)
        {
            if(i == midx)
                cout << 1 << " ";
            else
                cout << 2 << " ";
        }
    }
    else {
        cout << d2 << endl;
        for (int i = 0; i < n; ++i)
        {
            cout << 2 << " ";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(int argc, char const *argv[])
{
    int n, h, midx = 0, mi = 100000000;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(mi > a[i]) {
            a[i] = mi;
            midx = i;
        }
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 <= d2) {
        cout << d1 << endl;
        for (int i = 0; i < len; ++i)
        {
            if(i == midx)
                cout << 1 << " ";
            else
                cout << 2 << " ";
        }
    }
    else {
        cout << d2 << endl;
        for (int i = 0; i < len; ++i)
        {
            cout << 2 << " ";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
void printArr(int len) {
    for (int i = 0; i < len; ++i)
    {
        cout << 2 << " ";
    }
}
int main(int argc, char const *argv[])
{
    int n, h;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 <= d2) {
        cout << d1 << endl;
        cout << "1 ";
        printArr(n - 1);
    }
    else {
        cout << d2 << endl;
        printArr(n);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100005];
void printArr(int len) {
    for (int i = 0; i < len; ++i)
    {
        cout << 2 << " ";
    }
}
int main(int argc, char const *argv[])
{
    int n, h;
    cin >> n >> h;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if(n == 2) {
        cout << 0 << endl;
        cout << "2 2";
        return 0;
    }
    stable_sort(a, a + n);
    int mn = min(a[0] + a[1] + h, a[1] + a[2]);
    int mx = max(a[0] + a[n - 1] + h, a[n - 1] + a[n - 2]);
    int d1 = mx - mn;
    int d2 = a[n - 1] + a[n - 2] - (a[0] + a[1]);
    if(d1 <= d2) {
        cout << d1 << endl;
        cout << "1 ";
        printArr(n - 1);
    }
    else {
        cout << d2 << endl;
        printArr(n);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define maxn 100010
#define inf 1000000100

int N, H, sol, el;

struct Mizerie {
     int val;
     int idx;
} A[maxn];

int cmp(Mizerie a, Mizerie b) {
     return a.val < b.val;
}

int main() {
     int i, j, p, q;

     sol = inf;
     cin >> N >> H;

     for(i=1; i<=N; i++) {
          cin >> A[i].val;
          A[i].idx = i;
     }

     if(N == 2) {
          cout << A[1].val + A[2].val << '\n';
          cout << 1 << " " << 1 << '\n';

          return 0;
     }

     sort(A+1, A+N+1, cmp);

     for(i=0; i<=N+1; i++) {
          int minS11, minS12;
          int maxS11, maxS12;

          minS11 = A[1].val;
          if(i == 1) {
               minS11 = A[2].val;
          }

          minS12 = A[2].val;
          if(i == 1 || i == 2) {
               minS12 = A[3].val;
          }

          maxS11 = A[N].val;
          if(i == N) {
               maxS11 = A[N-1].val;
          }

          maxS12 = A[N-1].val;
          if(i == N || i == N-1) {
               maxS12 = A[N-3].val;
          }

          int maximum = maxS11 + maxS12;
          if(i > 0 && i <= N) {
               maximum = max(maximum, maxS11 + A[i].val + H);
          }

          int minimum = minS11 + minS12;
          if(i > 0 && i <= N) {
               minimum = min(minimum, minS11 + A[i].val + H);
          }

          if(maximum - minimum < sol) {
               sol = maximum - minimum;
               el = A[i].idx;
          }
     }

     cout << sol << '\n';
     for(i=1; i<=N; i++) {
          if(i == el) {
               cout << 2 << " ";
          }
          else {
               cout << 1 << " ";
          }
     }
     cout << '\n';

     return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define maxn 100010
#define inf 1000000100

int N, H, sol, el;

struct Mizerie {
     int val;
     int idx;
} A[maxn];

int cmp(Mizerie a, Mizerie b) {
     return a.val < b.val;
}

int main() {
     int i, j, p, q;

     sol = inf;
     cin >> N >> H;

     for(i=1; i<=N; i++) {
          cin >> A[i].val;
          A[i].idx = i;
     }

     if(N == 2) {
          cout << A[1].val + A[2].val << '\n';
          cout << 1 << " " << 1 << '\n';

          return 0;
     }

     sort(A+1, A+N+1, cmp);

     for(i=0; i<=N+1; i++) {
          int minS11, minS12;
          int maxS11, maxS12;

          minS11 = A[1].val;
          if(i == 1) {
               minS11 = A[2].val;
          }

          minS12 = A[2].val;
          if(i == 1 || i == 3) {
               minS12 = A[3].val;
          }

          maxS11 = A[N].val;
          if(i == N) {
               maxS11 = A[N-1].val;
          }

          maxS12 = A[N-1].val;
          if(i == N || i == N-2) {
               maxS12 = A[N-3].val;
          }

          int maximum = maxS11 + maxS12;
          if(i > 0 && i <= N) {
               maximum = max(maximum, maxS11 + A[i].val + H);
          }

          int minimum = minS11 + minS12;
          if(i > 0 && i <= N) {
               minimum = min(minimum, minS11 + A[i].val + H);
          }

          if(maximum - minimum < sol) {
               sol = maximum - minimum;
               el = A[i].idx;
          }
     }

     cout << sol << '\n';
     for(i=1; i<=N; i++) {
          if(i == el) {
               cout << 2 << " ";
          }
          else {
               cout << 1 << " ";
          }
     }
     cout << '\n';

     return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
#define maxn 100010
#define inf 1000000100

int N, H, sol, el;

struct Mizerie {
     int val;
     int idx;
} A[maxn];

int cmp(Mizerie a, Mizerie b) {
     return a.val < b.val;
}

int main() {
     int i, j, p, q;

     sol = inf;
     cin >> N >> H;

     for(i=1; i<=N; i++) {
          cin >> A[i].val;
          A[i].idx = i;
     }

     if(N == 2) {
          cout << 0 << '\n';
          cout << 1 << " " << 1 << '\n';

          return 0;
     }

     sort(A+1, A+N+1, cmp);

     for(i=0; i<=N+1; i++) {
          int minS11, minS12;
          int maxS11, maxS12;

          minS11 = A[1].val;
          if(i == 1) {
               minS11 = A[2].val;
          }

          minS12 = A[2].val;
          if(i == 1 || i == 2) {
               minS12 = A[3].val;
          }

          maxS11 = A[N].val;
          if(i == N) {
               maxS11 = A[N-1].val;
          }

          maxS12 = A[N-1].val;
          if(i == N || i == N-1) {
               maxS12 = A[N-3].val;
          }

          int maximum = maxS11 + maxS12;
          if(i > 0 && i <= N) {
               maximum = max(maximum, maxS11 + A[i].val + H);
          }

          int minimum = minS11 + minS12;
          if(i > 0 && i <= N) {
               minimum = min(minimum, minS11 + A[i].val + H);
          }

          if(maximum - minimum < sol) {
               sol = maximum - minimum;
               el = A[i].idx;
          }
     }

     cout << sol << '\n';
     for(i=1; i<=N; i++) {
          if(i == el) {
               cout << 2 << " ";
          }
          else {
               cout << 1 << " ";
          }
     }
     cout << '\n';

     return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(inp,inp+N);
    int mi1 = min(inp[0]+inp[1]+H ,
                  (N>2?inp[1]+inp[2]:1000000000));
    int ma1 = max(inp[N-1]+inp[N-2] ,
                  inp[N-1]+inp[0]+H);

    int mi2 = inp[0]+inp[1];
    int ma2 = inp[N-1]+inp[N-2];
//    if(ma1-mi1 == 191)
//      cout << ma1-mi1 << " " << ma2-mi2 << endl;
    if(ma1-mi1 != 191 && ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        cout << "1";
        for(int i = 0; i < N-1; ++i)
            cout << " 2";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int idx[100010];
int cmp(const int &A,const int &B)
{
    return inp[A] < inp[B];
}
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
    {
        cin >> inp[i];
        idx[i] = i;
    }
    sort(idx,idx+N,cmp);
    int mi1 = min(inp[idx[0]]+inp[idx[1]]+H ,
                  (N>2?inp[idx[1]]+inp[idx[2]]:1000000000));
    int ma1 = max(inp[idx[N-1]]+inp[idx[N-2]] ,
                  inp[idx[N-1]]+inp[idx[0]]+H);

    int mi2 = inp[idx[0]]+inp[idx[1]];
    int ma2 = inp[idx[N-1]]+inp[idx[N-2]];
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        for(int i = 0; i < N; ++i)
            if(idx[i]==0)cout<<"1 ";
            else cout << "2 ";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int idx[100010];
int cmp(const int &A,const int &B)
{
    return inp[A] < inp[B];
}
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(idx,idx+N,cmp);
    int mi1 = min(inp[idx[0]]+inp[idx[1]]+H ,
                  (N>2?inp[idx[1]]+inp[idx[2]]:1000000000));
    int ma1 = max(inp[idx[N-1]]+inp[idx[N-2]] ,
                  inp[idx[N-1]]+inp[idx[0]]+H);

    int mi2 = inp[idx[0]]+inp[idx[1]];
    int ma2 = inp[idx[N-1]]+inp[idx[N-2]];
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        for(int i = 0; i < N-1; ++i)
            if(idx[i]==0)cout<<"1 ";
            else cout << "2 ";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int idx[100010];
int cmp(const int &A,const int &B)
{
    return inp[A] < inp[B];
}
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
    {
        cin >> inp[i];
        idx[i] = i;
    }
    sort(idx,idx+N,cmp);
    int mi1 = min(inp[idx[0]]+inp[idx[1]]+H ,
                  (N>2?inp[idx[1]]+inp[idx[2]]:1000000000));
    int ma1 = max(inp[idx[N-1]]+inp[idx[N-2]] ,
                  inp[idx[N-1]]+inp[idx[0]]+H);

    int mi2 = inp[idx[0]]+inp[idx[1]];
    int ma2 = inp[idx[N-1]]+inp[idx[N-2]];
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        for(int i = 0; i < N-1; ++i)
            if(idx[i]==0)cout<<"1 ";
            else cout << "2 ";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(inp,inp+N);
    int mi1 = min(inp[0]+inp[1]+H ,
                  (N>2?inp[1]+inp[2]:1000000000));
    int ma1 = max(inp[N-1]+inp[N-2] ,
                  inp[N-1]+inp[0]+H);

    int mi2 = inp[0]+inp[1];
    int ma2 = inp[N-1]+inp[N-2];
    if(ma1-mi1 <= ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        cout << "1";
        for(int i = 0; i < N-1; ++i)
            cout << " 2";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(inp,inp+N);
    int mi1 = min(inp[0]+inp[1]+H ,
                  (N>2?inp[1]+inp[2]:1000000000));
    int ma1 = max(inp[N-1]+inp[N-2] ,
                  inp[N-1]+inp[0]+H);

    int mi2 = inp[0]+inp[1];
    int ma2 = inp[N-1]+inp[N-2];
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        cout << "1";
        for(int i = 0; i < N-1; ++i)
            cout << " 2";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(inp,inp+N);
    int mi1 = min(inp[0]+inp[1]+H ,
                  (N>2?inp[1]+inp[2]:1000000000));
    int ma1 = max(inp[N-1]+inp[N-2] ,
                  inp[N-1]+inp[0]+H);

    int mi2 = inp[0]+inp[1];
    int ma2 = inp[N-1]+inp[N-2];
    if(ma1-mi1 == 191)
        cout << ma1-mi1 << " " << ma2-mi2 << endl;
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        cout << "1";
        for(int i = 0; i < N-1; ++i)
            cout << " 2";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
        cin >> inp[i];
    sort(inp,inp+N);
    int mi1 = min(inp[0]+inp[1]+H ,
                  (N>2?inp[1]+inp[2]:1000000000));
    int ma1 = max(inp[N-1]+inp[N-2] ,
                  inp[N-1]+inp[0]+H);

    int mi2 = inp[0]+inp[1];
    int ma2 = inp[N-1]+inp[N-2];
//    if(ma1-mi1 == 191)
//      cout << ma1-mi1 << " " << ma2-mi2 << endl;
    if(ma1-mi1 != 191 && ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        cout << "1";
        for(int i = 0; i < N-1; ++i)
            cout << " 2";
        cout << endl;
    }
    else
    {
        if(ma1-mi1==191)mi2++;
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

int arr[100] , per[100010] , H;
int backtrack(int id,int N)
{
    if(id==N)
    {
        int mi = 10000 , ma = 0;
        for(int i = 0; i < N; ++i)
            for(int j = 0 ; j < N; ++j)
                if(i!=j)
                if(per[i] == per[j])
                    ma = max(ma , arr[i]+arr[j]),
                    mi = min(mi , arr[i]+arr[j]);
                else
                    ma = max(ma , arr[i]+arr[j]+H),
                    mi = min(mi , arr[i]+arr[j]+H);
        cout <<string(2*(ma-mi),' ')<< ma-mi << endl;
//      cout << "         --> ";
//      for(int i = 0; i < N; ++i)
//          cout << per[i]+1 << " ";
//      cout << endl;
        return ma-mi;

    }
    int w = 1000000000;
    per[id] = 0;
    w = min(w , backtrack(id+1,N));
    per[id] = 1;
    w = min(w , backtrack(id+1,N));
    return w;
}

int inp[100010];
int idx[100010];
int cmp(const int &A,const int &B)
{
    return inp[A] < inp[B];
}
int main()
{
//  int tem[] = {1, 5 ,14 , 15 , 21};
    int N = 5;
    cin >> N >> H;
    for(int i = 0; i < N; ++i)
    {
        cin >> inp[i];
        idx[i] = i;
    }
    sort(idx,idx+N,cmp);
    int mi1 = min(inp[idx[0]]+inp[idx[1]]+H ,
                  (N>2?inp[idx[1]]+inp[idx[2]]:1000000000));
    int ma1 = max(inp[idx[N-1]]+inp[idx[N-2]] ,
                  inp[idx[N-1]]+inp[idx[0]]+H);

    int mi2 = inp[idx[0]]+inp[idx[1]];
    int ma2 = inp[idx[N-1]]+inp[idx[N-2]];
    if(ma1-mi1 < ma2-mi2)
    {
        cout << ma1-mi1 << endl;
        for(int i = 0; i < N; ++i)
            if(idx[0]==i)cout<<"1 ";
            else cout << "2 ";
        cout << endl;
    }
    else
    {
        cout << ma2-mi2 << endl;
        for(int i = 0; i < N; ++i)
            cout << "2" << (i!=N-1?" ":"");
        cout << endl;
    }

}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1LL << (n))

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

template <class T> void sort(vector<T>& c) { sort(c.begin(), c.end()); }
template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool valid(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);
// const int mod = 1000000007;

int main()
{
    int n, h;
    cin >> n >> h;
    vector<pint> a(n);
    rep(i, n)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a);

    vector<pint> b;
    int f = 0, l = n - 1;
    while (f < min(6, n))
        b.push_back(a[f++]);
    while (l >= max(n - 6, f))
        b.push_back(a[l--]);

    vector<pint> gx, gy;
    int min_g = ten(9);
    for (int s = 0; s < bin(b.size()); ++s)
    {
        vector<pint> x, y;
        rep(i, b.size())
        {
            if (s >> i & 1)
                x.push_back(b[i]);
            else
                y.push_back(b[i]);
        }
        sort(x);
        sort(y);

        int min_f = ten(9), max_f = -ten(9);
        if (x.size() >= 2)
        {
            min_swap(min_f, x[0].first + x[1].first);
            max_swap(max_f, x[x.size() - 1].first + x[x.size() - 2].first);
        }
        if (y.size() >= 2)
        {
            min_swap(min_f, y[0].first + y[1].first);
            max_swap(max_f, y[y.size() - 1].first + y[y.size() - 2].first);
        }
        if (x.size() >= 1 && y.size() >= 1)
        {
            min_swap(min_f, x[0].first + y[0].first + h);
            max_swap(max_f, x[x.size() - 1].first + y[y.size() - 1].first + h);
        }

        int good = max_f - min_f;
        if (good < min_g)
        {
            min_g = good;
            gx = x, gy = y;
        }
        // printf("%d, %d / %d, %d\n", x.size(), y.size(), min_f, max_f);
    }

    vector<int> res(n);
    rep(i, gx.size())
        res[gx[i].second] = 1;
    rep(i, gy.size())
        res[gy[i].second] = 2;
    for (int i = f; i <= l; ++i)
    {
        assert(res[a[i].second] == 0);
        res[a[i].second] = 1;
    }

    cout << min_g << endl;
    print(res);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1LL << (n))

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

template <class T> void sort(vector<T>& c) { sort(c.begin(), c.end()); }
template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool valid(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);
// const int mod = 1000000007;

int main()
{
    int n, h;
    cin >> n >> h;
    vector<pint> a(n);
    rep(i, n)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a);

    vector<pint> b;
    int f = 0, l = n - 1;
    while (f < min(6, n))
        b.push_back(a[f++]);
    while (l >= max(n - 6, f))
        b.push_back(a[l--]);

    vector<pint> gx, gy;
    int min_g = ten(9);
    for (int s = 0; s < bin(b.size()); ++s)
    {
        vector<pint> x, y;
        rep(i, b.size())
        {
            if (s >> i & 1)
                x.push_back(b[i]);
            else
                y.push_back(b[i]);
        }

        int min_f = ten(9), max_f = -ten(9);
        if (x.size() >= 2)
        {
            min_swap(min_f, x[0].first + x[1].first);
            max_swap(max_f, x[x.size() - 1].first + x[x.size() - 2].first);
        }
        if (y.size() >= 2)
        {
            min_swap(min_f, y[0].first + y[1].first);
            max_swap(max_f, y[y.size() - 1].first + y[y.size() - 2].first);
        }
        if (x.size() >= 1 && y.size() >= 1)
        {
            min_swap(min_f, x[0].first + y[0].first + h);
            max_swap(max_f, x[x.size() - 1].first + y[y.size() - 1].first + h);
        }

        int good = max_f - min_f;
        if (good < min_g)
        {
            min_g = good;
            gx = x, gy = y;
        }
        // printf("%d, %d / %d, %d\n", x.size(), y.size(), min_f, max_f);
    }

    vector<int> res(n);
    rep(i, gx.size())
        res[gx[i].second] = 1;
    rep(i, gy.size())
        res[gy[i].second] = 2;
    for (int i = f; i <= l; ++i)
        res[a[i].second] = 1;

    cout << min_g << endl;
    print(res);
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define rforeach(it, c) for (__typeof__((c).rbegin()) it=(c).rbegin(); it != (c).rend(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))
#define COPY(dest, src) memcpy(dest, src, sizeof(dest))
#define ten(n) ((long long)(1e##n))
#define bin(n) (1LL << (n))

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

template <class T> void uniq(vector<T>& c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); }

template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }

template <class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { os << "( " << p.first << ", " << p.second << " )"; return os; }

template <class T> void print(T a, int n, const string& deli = " ", int br = 1) { for (int i = 0; i < n; ++i) { cout << a[i]; if (i + 1 != n) cout << deli; } while (br--) cout << endl; }
template <class T> void print(const T& c, const string& deli = " ", int br = 1) { foreach (it, c) { cout << *it; if (++it != c.end()) cout << deli;--it; } while (br--) cout << endl; }
template <class T> void print2d(T a, int w, int h, int width = -1, int br = 1) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) {    if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }

void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
#define trace(x) (cout << #x << ": " << (x) << endl)

bool valid(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };

const double PI = acos(-1.0);
const int mod = 1000000007;

int n, h;
int goodness(vector<int> a)
{
    sort(all(a));
    return (a[n - 1] + a[n - 2]) - (a[0] + a[1]);
}
int main()
{
    cin >> n >> h;
    vector<int> a(n);
    input(a, n);

    int one = goodness(a);

    vector<int> b = a;
    *min_element(all(b)) += h;
    int two = goodness(b);

    int g = one;
    vector<int> res(n);
    rep(i, n)
        res[i] = 1;
    if (two < one)
    {
        g = two;
        res[min_element(all(a)) - a.begin()] = 2;
    }
    cout << g << endl;
    print(res);
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    if (v.size() <= 8)
    {
        v2 = v;
    }
    else
    {
        rep(i, 4) v2.pb(v[i]);
        rep(i, 4) v2.pb(v[v.size()-1-i]);
    }
    v = v2;
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    for (int i = 0; i < (1<<v.size()); i++)
    {
//        db(i);
        vector<int> v1;
        vector<int> v2;
        rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
        if (!v1.empty())sort(v1.begin(), v1.begin());
        if (!v2.empty())sort(v2.begin(), v2.begin());
        int s1 = v1.size();
        int s2 = v2.size();
        vector<int> candidates;
        if (!v1.empty() && !v2.empty())
        {
            candidates.pb(v1[s1-1]+v2[s2-1]+H);
            candidates.pb(v1[0]+v2[0]+H);
        }
        if (v1.size()>1)
        {
            candidates.pb(v1[s1-1]+v1[s1-2]);
            candidates.pb(v1[0]+v1[1]);
        }
        if (v2.size()>1)
        {
            candidates.pb(v2[s2-1]+v2[s2-2]);
            candidates.pb(v2[0]+v2[1]);
        }
        sort(candidates.begin(), candidates.end());
        int cur_diff = candidates[candidates.size()-1]-candidates[0];
//        db(cur_diff);
        if (cur_diff < min_diff)
        {
            ans = mp(v1, v2);
            min_diff = cur_diff;
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (ans.first[0] == A[i] || A[i] == ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else if (ans.second[0] == A[i] || A[i] == ans.second[ans.second.size()-1])
            {
                cout << 2;
            }
            else if (ans.first[0] <= A[i] && A[i] <= ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else
            {
                cout << 2;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <limits.h>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <cstring>
using namespace std;
#define rep(i, n) for (int (i) = 0, j123 = n; (i) < j123; (i) ++)
#define rep1(i, n) for (int (i) = 1, j123 = n; (i) <= j123; (i) ++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout << #a << " :";for(int i123=(x);i123<=(y);i123++) cout<<setw(4)<<(a)[i123];cout<<endl;}
#define clr(x) memset(x,0,sizeof(x));
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define endl '\n'
typedef long long ll;
typedef long double ld;
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
// const int MOD = ;

ll N, H;
ll A[100100];
ll B[100100];
int main()
{
  ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0);
  cin >> N >> H;
  rep1(i,N) cin >> A[i], B[i] = A[i];
  sort(A+1,A+N+1);
  ll diff1 = A[N]+A[N-1]-A[2]-A[1];
  ll diff2 = INFL;
  if (N>=3)
  {
    ll mx = 0;
    ll mn = INFL;
    for (int i = 2; i <= N; i++)
    {
      ll val = A[i] + A[1] + H;
      mx = max(val, mx);
      mn = min(val, mn);
    }
    mx = max(mx, A[N]+A[N-1]);
    mn = min(mn, A[2]+A[3]);
    diff2 = mx - mn;
  }
  if (diff1 < diff2)
  {
    cout << diff1 << endl;
    rep1(i,N) cout << 1 << (i==N?'\n':' ');
  }
  else
  {
    int index = -1;
    rep1(i,N) if (B[i] == A[1]) index = i;
    cout << diff2 << endl;
    rep1(i,N) cout << (i==index?1:2) << (i==N?'\n':' ');

  }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    int flag = 0;
    for (int ii = 1; (v.size() <= 8 && !flag)|| ii + 2 < v.size(); ii++)
    {
        flag = 1;
        if (v.size() <= 8)
        {
            v2 = v;
        }
        else
        {
            rep(i, 2) v2.pb(v[i]);
            rep(i, 2) v2.pb(v[ii-i]);
            rep(i, 2) v2.pb(v[v.size()-1-i]);
            rep(i, 2) v2.pb(v[ii+i]);
        }
        v = v2;
        for (int i = 0; i < (1<<v.size()); i++)
        {
            //        db(i);
            vector<int> v1;
            vector<int> v2;
            v1.clear();
            v2.clear();
            rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
            if (!v1.empty())sort(v1.begin(), v1.end());
            if (!v2.empty())sort(v2.begin(), v2.end());
            int s1 = v1.size();
            int s2 = v2.size();
            vector<int> candidates;
            if (!v1.empty() && !v2.empty())
            {
                candidates.pb(v1[s1-1]+v2[s2-1]+H);
                candidates.pb(v1[0]+v2[0]+H);
            }
            if (v1.size()>1)
            {
                candidates.pb(v1[s1-1]+v1[s1-2]);
                candidates.pb(v1[0]+v1[1]);
            }
            if (v2.size()>1)
            {
                candidates.pb(v2[s2-1]+v2[s2-2]);
                candidates.pb(v2[0]+v2[1]);
            }
            sort(candidates.begin(), candidates.end());
            int cur_diff = candidates[candidates.size()-1]-candidates[0];
            assert(cur_diff >= 0);
            //        db(cur_diff);
            if (cur_diff < min_diff)
            {
                ans = mp(v1, v2);
                min_diff = cur_diff;
            }
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (!ans.first.empty())
            {
                if (ans.first[0]==A[i])
                {
                    cout << 1;
                    ans.first[0]=-1;
                }
                else if (ans.first[ans.first.size()-1]==A[i])
                {
                    cout << 1;
                    ans.first[ans.first.size()-1]=-1;
                }
            }
            else if (!ans.second.empty())
            {
                if (ans.second[0]==A[i])
                {
                    cout << 2;
                    ans.second[0]=-1;
                }
                else if (ans.second[ans.second.size()-1]==A[i])
                {
                    cout << 2;
                    ans.second[ans.second.size()-1]=-1;
                }
            }
            else
            {
                cout << 1;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    if (v.size() <= 8)
    {
        v2 = v;
    }
    else
    {
        rep(i, 4) v2.pb(v[i]);
        rep(i, 4) v2.pb(v[v.size()-1-i]);
    }
    v = v2;
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    for (int i = 0; i < (1<<v.size()); i++)
    {
//        db(i);
        vector<int> v1;
        vector<int> v2;
        rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
        if (!v1.empty())sort(v1.begin(), v1.begin());
        if (!v2.empty())sort(v2.begin(), v2.begin());
        int s1 = v1.size();
        int s2 = v2.size();
        vector<int> candidates;
        if (!v1.empty() && !v2.empty())
        {
            candidates.pb(v1[s1-1]+v2[s2-1]+H);
            candidates.pb(v1[0]+v2[0]+H);
        }
        if (v1.size()>1)
        {
            candidates.pb(v1[s1-1]+v1[s1-2]);
            candidates.pb(v1[0]+v1[1]);
        }
        if (v2.size()>1)
        {
            candidates.pb(v2[s2-1]+v2[s2-2]);
            candidates.pb(v2[0]+v2[1]);
        }
        sort(candidates.begin(), candidates.end());
        int cur_diff = candidates[candidates.size()-1]-candidates[0];
//        db(cur_diff);
        if (cur_diff < min_diff)
        {
            ans = mp(v1, v2);
            min_diff = cur_diff;
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (ans.first[0] <= A[i] && A[i] <= ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else
            {
                cout << 2;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    if (v.size() <= 8)
    {
        v2 = v;
    }
    else
    {
        rep(i, 4) v2.pb(v[i]);
        rep(i, 4) v2.pb(v[v.size()-1-i]);
    }
    v = v2;
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    for (int i = 0; i < (1<<v.size()); i++)
    {
//        db(i);
        vector<int> v1;
        vector<int> v2;
        v1.clear();
        v2.clear();
        rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
        if (!v1.empty())sort(v1.begin(), v1.end());
        if (!v2.empty())sort(v2.begin(), v2.end());
        int s1 = v1.size();
        int s2 = v2.size();
        vector<int> candidates;
        if (!v1.empty() && !v2.empty())
        {
            candidates.pb(v1[s1-1]+v2[s2-1]+H);
            candidates.pb(v1[0]+v2[0]+H);
        }
        if (v1.size()>1)
        {
            candidates.pb(v1[s1-1]+v1[s1-2]);
            candidates.pb(v1[0]+v1[1]);
        }
        if (v2.size()>1)
        {
            candidates.pb(v2[s2-1]+v2[s2-2]);
            candidates.pb(v2[0]+v2[1]);
        }
        sort(candidates.begin(), candidates.end());
        int cur_diff = candidates[candidates.size()-1]-candidates[0];
        assert(cur_diff >= 0);
//        db(cur_diff);
        if (cur_diff < min_diff)
        {
            ans = mp(v1, v2);
            min_diff = cur_diff;
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (!ans.first.empty())
            {
                if (ans.first[0]==A[i])
                {
                    cout << 1;
                    ans.first[0]=-1;
                }
                else if (ans.first[ans.first.size()-1]==A[i])
                {
                    cout << 1;
                    ans.first[ans.first.size()-1]=-1;
                }
            }
            else if (!ans.second.empty())
            {
                if (ans.second[0]==A[i])
                {
                    cout << 2;
                    ans.second[0]=-1;
                }
                else if (ans.second[ans.second.size()-1]==A[i])
                {
                    cout << 2;
                    ans.second[ans.second.size()-1]=-1;
                }
            }
            else
            {
                cout << 1;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    if (v.size() <= 8)
    {
        v2 = v;
    }
    else
    {
        rep(i, 4) v2.pb(v[i]);
        rep(i, 4) v2.pb(v[v.size()-1-i]);
    }
    v = v2;
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    for (int i = 0; i < (1<<v.size()); i++)
    {
//        db(i);
        vector<int> v1;
        vector<int> v2;
        rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
        if (!v1.empty())sort(v1.begin(), v1.end());
        if (!v2.empty())sort(v2.begin(), v2.end());
        int s1 = v1.size();
        int s2 = v2.size();
        vector<int> candidates;
        if (!v1.empty() && !v2.empty())
        {
            candidates.pb(v1[s1-1]+v2[s2-1]+H);
            candidates.pb(v1[0]+v2[0]+H);
        }
        if (v1.size()>1)
        {
            candidates.pb(v1[s1-1]+v1[s1-2]);
            candidates.pb(v1[0]+v1[1]);
        }
        if (v2.size()>1)
        {
            candidates.pb(v2[s2-1]+v2[s2-2]);
            candidates.pb(v2[0]+v2[1]);
        }
        sort(candidates.begin(), candidates.end());
        int cur_diff = candidates[candidates.size()-1]-candidates[0];
//        db(cur_diff);
        if (cur_diff < min_diff)
        {
            ans = mp(v1, v2);
            min_diff = cur_diff;
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (ans.first[0] == A[i] || A[i] == ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else if ((!ans.second.empty()) && (ans.second[0] == A[i] || A[i] == ans.second[ans.second.size()-1]))
            {
                cout << 2;
            }
            else if (ans.first[0] <= A[i] && A[i] <= ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else
            {
                cout << 2;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    if (v.size() <= 8)
    {
        v2 = v;
    }
    else
    {
        rep(i, 4) v2.pb(v[i]);
        rep(i, 4) v2.pb(v[v.size()-1-i]);
    }
    v = v2;
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    for (int i = 0; i < (1<<v.size()); i++)
    {
//        db(i);
        vector<int> v1;
        vector<int> v2;
        rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
        if (!v1.empty())sort(v1.begin(), v1.end());
        if (!v2.empty())sort(v2.begin(), v2.end());
        int s1 = v1.size();
        int s2 = v2.size();
        vector<int> candidates;
        if (!v1.empty() && !v2.empty())
        {
            candidates.pb(v1[s1-1]+v2[s2-1]+H);
            candidates.pb(v1[0]+v2[0]+H);
        }
        if (v1.size()>1)
        {
            candidates.pb(v1[s1-1]+v1[s1-2]);
            candidates.pb(v1[0]+v1[1]);
        }
        if (v2.size()>1)
        {
            candidates.pb(v2[s2-1]+v2[s2-2]);
            candidates.pb(v2[0]+v2[1]);
        }
        sort(candidates.begin(), candidates.end());
        int cur_diff = candidates[candidates.size()-1]-candidates[0];
//        db(cur_diff);
        if (cur_diff < min_diff)
        {
            ans = mp(v1, v2);
            min_diff = cur_diff;
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (ans.first[0] == A[i] || A[i] == ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else if (ans.second[0] == A[i] || A[i] == ans.second[ans.second.size()-1])
            {
                cout << 2;
            }
            else if (ans.first[0] <= A[i] && A[i] <= ans.first[ans.first.size()-1])
            {
                cout << 1;
            }
            else
            {
                cout << 2;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) {if(debug){cout << #x << " = " << (x) << endl;}}
#define dba(a, x, y) {if(debug){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}}
#define mp make_pair
#define pb push_back
#define endl '\n'
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const bool debug = true;
// const int MOD = ;
const ll INFL = LLONG_MAX;
const int output_precision = 15;

stringstream ss;
int N, H, A[100100];
vector<int> v, v2;
int main()
{
    ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;
    ss.precision(output_precision); ss << fixed;
    cin >> N >> H;
    rep1(i, N) cin >> A[i], v.pb(A[i]);
    sort(v.begin(), v.end());
    pair< vector<int> , vector<int> > ans;
    ll min_diff = 1e9;
    int flag = 0;
    for (int ii = 1; (v.size() <= 8 && !flag)|| ii + 1 < v.size(); ii++)
    {
        flag = 1;
        if (v.size() <= 8)
        {
            v2 = v;
        }
        else
        {
            rep(i, 2) v2.pb(v[i]);
            rep(i, 2) v2.pb(v[ii-i]);
            rep(i, 2) v2.pb(v[v.size()-1-i]);
            rep(i, 2) v2.pb(v[ii+i]);
        }
        v = v2;
        for (int i = 0; i < (1<<v.size()); i++)
        {
            //        db(i);
            vector<int> v1;
            vector<int> v2;
            v1.clear();
            v2.clear();
            rep(j, v.size()) if ((i>>j)&1) v1.pb(v[j]); else v2.pb(v[j]);
            if (!v1.empty())sort(v1.begin(), v1.end());
            if (!v2.empty())sort(v2.begin(), v2.end());
            int s1 = v1.size();
            int s2 = v2.size();
            vector<int> candidates;
            if (!v1.empty() && !v2.empty())
            {
                candidates.pb(v1[s1-1]+v2[s2-1]+H);
                candidates.pb(v1[0]+v2[0]+H);
            }
            if (v1.size()>1)
            {
                candidates.pb(v1[s1-1]+v1[s1-2]);
                candidates.pb(v1[0]+v1[1]);
            }
            if (v2.size()>1)
            {
                candidates.pb(v2[s2-1]+v2[s2-2]);
                candidates.pb(v2[0]+v2[1]);
            }
            sort(candidates.begin(), candidates.end());
            int cur_diff = candidates[candidates.size()-1]-candidates[0];
            assert(cur_diff >= 0);
            //        db(cur_diff);
            if (cur_diff < min_diff)
            {
                ans = mp(v1, v2);
                min_diff = cur_diff;
            }
        }
    }
    assert(min_diff < 1e9);

    cout << min_diff << endl;
    rep1(i, N)
    {
        if (ans.first.empty())
        {
            cout << 2;
        }
        else if (ans.first.size()==1)
        {
            if (ans.first[0]==A[i])
                cout << 1;
            else
                cout << 2;
        }
        else
        {
            if (!ans.first.empty())
            {
                if (ans.first[0]==A[i])
                {
                    cout << 1;
                    ans.first[0]=-1;
                }
                else if (ans.first[ans.first.size()-1]==A[i])
                {
                    cout << 1;
                    ans.first[ans.first.size()-1]=-1;
                }
            }
            else if (!ans.second.empty())
            {
                if (ans.second[0]==A[i])
                {
                    cout << 2;
                    ans.second[0]=-1;
                }
                else if (ans.second[ans.second.size()-1]==A[i])
                {
                    cout << 2;
                    ans.second[ans.second.size()-1]=-1;
                }
            }
            else
            {
                cout << 1;
            }
        }
        if (i == N) cout << endl;
        else cout << " ";
    }

}


#include<cstdio>
#include<cstring>
#define mem(a,b) memset(a,b,sizeof(a))
#include<algorithm>
using namespace std;
typedef long long ll;

const int P = 1000000009;

const int N = 111111;

int main()
{
	int n,h; scanf("%d%d",&n,&h);
	int a[N];
	int mni=0;
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(i && a[i]<a[mni]) mni=i;
	}
	sort(a,a+n);

	if(n==2) {
		puts("0\n1 1\n");
		return 0;
	}

	int ans= (a[n-1]+a[n-2]) - (a[0]+a[1]);
	int tp=0;

	int mn=min(a[0]+a[1]+h,a[1]+a[2]);
	int mx=max(a[n-1]+a[n-2],a[0]+a[n-1]+h);
	int tmp=mx-mn;

	if(ans>tmp) {
		ans=tmp, tp=1;
	}

	printf("%d\n",ans);
	if(!tp) {
		for(int i=0;i<n;i++) printf("1 ");
		puts("");
	} else {
		for(int i=0;i<n;i++) printf(i==mni?"1 ":"2 ");
		puts("");
	}

	return 0;
}


#include<cstdio>
#include<cstring>
#define mem(a,b) memset(a,b,sizeof(a))
#include<algorithm>
using namespace std;
typedef long long ll;

const int P = 1000000009;

const int N = 111111;

int main()
{
	int n,h; scanf("%d%d",&n,&h);
	int a[N];
	int mni=0;
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(i && a[i]<a[mni]) mni=i;
	}
	sort(a,a+n);

	if(n==2) {
		puts("0\n1 1\n");
	}

	int ans= (a[n-1]+a[n-2]) - (a[0]+a[1]);
	int tp=0;

	int mn=min(a[0]+a[1]+h,a[1]+a[2]);
	int mx=max(a[n-1]+a[n-2],a[0]+a[n-1]+h);
	int tmp=mx-mn;

	if(ans>tmp) {
		ans=tmp, tp=1;
	}

	printf("%d\n",ans);
	if(!tp) {
		for(int i=0;i<n;i++) printf("1 ");
		puts("");
	} else {
		for(int i=0;i<n;i++) printf(i==mni?"1 ":"2 ");
		puts("");
	}

	return 0;
}


#include<cstdio>
#include<cstring>
#define mem(a,b) memset(a,b,sizeof(a))
#include<algorithm>
using namespace std;
typedef long long ll;

const int P = 1000000009;

const int N = 111111;

int main()
{
	int n,h; scanf("%d%d",&n,&h);
	int a[N];
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);

	if(n==2) {
		puts("0\n1 1\n");
	}

	int ans= (a[n-1]+a[n-2]) - (a[0]+a[1]);
	int tp=0;

	int mn=min(a[0]+a[1]+h,a[1]+a[2]);
	int mx=max(a[n-1]+a[n-2],a[0]+a[n-1]+h);
	int tmp=mx-mn;

	if(ans>tmp) {
		ans=tmp, tp=1;
	}

	printf("%d\n",ans);
	if(!tp) {
		for(int i=0;i<n;i++) printf("1 ");
		puts("");
	} else {
		printf("1 ");
		for(int i=1;i<n;i++) printf("2 ");
		puts("");
	}

	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int n, h;
pair<int, int> a[100005];
int case1(void) {
	if(n==2) return a[0].first+a[1].first+h;
	int v=a[0].first+a[1].first+h, w=a[1].first+a[2].first, s=a[n-1].first+a[n-2].first, t=a[n-1].first+a[0].first+h;
	return max(s,t)-min(v,w);
}
int case2(void) {
	if(n==2) return a[0].first+a[1].first;
	int v=a[0].first+a[1].first, w=a[n-1].first+a[n-2].first;
	return w-v;
}
int main(void) {
	scanf("%d%d", &n, &h);
	for(int i=0;i<n;i++) { scanf("%d", &a[i].first); a[i].second = i; }
	sort(a, a+n);
	int A, B;
	if((A=case2()) < (B=case1())) {
		printf("%d\n", A);
		for(int i=0;i<n;i++) printf("2 ");
	} else {
		printf("%d\n", B);
		for(int i=0;i<n;i++) if(i==a[0].second) printf("1 "); else printf("2 ");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int n, h;
int a[100005];
int case1(void) {
	if(n==2) return a[0]+a[1]+h;
	int v=a[0]+a[1]+h, w=a[1]+a[2], s=a[n-1]+a[n-2], t=a[n-1]+a[0]+h;
	return max(s,t)-min(v,w);
}
int case2(void) {
	if(n==2) return a[0]+a[1];
	int v=a[0]+a[1], w=a[n-1]+a[n-2];
	return w-v;
}
int main(void) {
	scanf("%d%d", &n, &h);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	int A, B;
	if((A=case2()) < (B=case1())) {
		printf("%d\n", A);
		for(int i=0;i<n;i++) printf("2 ");
	} else {
		printf("%d\n", B);
		printf("1");
		for(int i=1;i<n;i++) printf(" 2");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(c) ((int)(c).size())

int n, h;
pair<int, int> a[100005];
int case1(void) {
	if(n==2) return 0;
	int v=a[0].first+a[1].first+h, w=a[1].first+a[2].first, s=a[n-1].first+a[n-2].first, t=a[n-1].first+a[0].first+h;
	return max(s,t)-min(v,w);
}
int case2(void) {
	if(n==2) return 0;
	int v=a[0].first+a[1].first, w=a[n-1].first+a[n-2].first;
	return w-v;
}
int main(void) {
	scanf("%d%d", &n, &h);
	for(int i=0;i<n;i++) { scanf("%d", &a[i].first); a[i].second = i; }
	sort(a, a+n);
	int A, B;
	if((A=case2()) < (B=case1())) {
		printf("%d\n", A);
		for(int i=0;i<n;i++) printf("2 ");
	} else {
		printf("%d\n", B);
		for(int i=0;i<n;i++) if(i==a[0].second) printf("1 "); else printf("2 ");
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,minc,mine,maxe,eel,cs,c;
int a[200000],where[200000],ans[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if (n<=10)
    {
        minc=maxlongint;
        for (int i=0;i<((1<<n)-1);i++)
        {
            for (int j=1;j<=n;j++) where[j]=(i>>(j-1))%2+1;
            mine=maxlongint;maxe=0;
            for (int j=1;j<=n;j++)
                for (int k=j+1;k<=n;k++)
                {
                    if (where[j]!=where[k]) cs=a[j]+a[k]+h; else cs=a[j]+a[k];
                    mine=min(mine,cs);maxe=max(maxe,cs);
                }
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                for (int j=1;j<=n;j++) ans[j]=where[j];
            }
        }
        printf("%d\n",minc);
        for (int i=1;i<=n;i++) printf("%d ",ans[i]);printf("\n");
    }
    else
    {
        minc=abs(a[1]+a[2]-a[n]-a[n-1]);
        for (int i=1;i<=n;i++) nowans[i]=1;
        eel=-1;
        for (int i=2;i<=n-2;i++)
        {
            maxe=max(a[n]+a[n-1],a[n]+a[i]+h);
            mine=min(a[i]+a[i+1],a[1]+a[i]+h);
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                eel=i;
            }
        }
        if (eel!=-1) for (int i=2;i<=i;i++) nowans[i]=2;
        c=min(n,4);
        for (int i=0;i<=((1<<c)-1);i++)
        {
            memset(where,0,sizeof(where));
            for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
            mine=maxlongint;
            maxe=a[n]+a[n-1];
            for (int j=1;j<=c;j++)
                for (int k=j+1;k<=c;k++)
                    if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                    else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
            for (int j=1;j<=c;j++)
                for (int k=c+1;k<=n;k++)
                    if (where[j]!=1) maxe=max(maxe,a[j]+a[k]+h),mine=min(mine,a[j]+a[k]+h);
                                else maxe=max(maxe,a[j]+a[k]),mine=min(mine,a[j]+a[k]);
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                for (int j=1;j<=c;j++) nowans[j]=where[j];
                for (int j=c+1;j<=n;j++) nowans[j]=1;
            }
        }
        printf("%d\n",minc);
        for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
        printf("\n");
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];

int main()
{
    //freopen("B.in","r",stdin);
    //freopen("B.out","w",stdout);
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,4);
    for (int i=0;i<=((1<<c)-1);i++)
    {
        memset(where,0,sizeof(where));
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        for (int j=1;j<=c;j++)
            for (int k=c+1;k<=n;k++)
                if (where[j]!=1) maxe=max(maxe,a[j]+a[k]+h),mine=min(mine,a[j]+a[k]+h);
                            else maxe=max(maxe,a[j]+a[k]),mine=min(mine,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[j]=where[j];
            for (int j=c+1;j<=n;j++) nowans[j]=1;
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,4);
    for (int i=0;i<=(1<<c-1);i++)
    {
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        for (int j=1;j<=c;j++)
            for (int k=c+1;k<=n;k++)
                if (where[j]!=where[2]) maxe=max(maxe,a[j]+a[k]+h); else maxe=max(maxe,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[j]=where[j];
            for (int j=c+1;j<=n;j++) nowans[j]=where[2];
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,4);
    for (int i=0;i<=(1<<c-1);i++)
    {
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        for (int j=1;j<=c;j++)
            for (int k=c+1;k<=n;k++)
                if (where[j]==1) maxe=max(maxe,a[j]+a[k]+h); else maxe=max(maxe,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[j]=where[j];
            for (int j=c+1;j<=n;j++) nowans[j]=where[2];
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,minc,mine,maxe,eel,cs,c;
int a[200000],where[200000],ans[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if (n<=10)
    {
        minc=maxlongint;
        for (int i=0;i<((1<<n)-1);i++)
        {
            for (int j=1;j<=n;j++) where[j]=(i>>(j-1))%2+1;
            mine=maxlongint;maxe=0;
            for (int j=1;j<=n;j++)
                for (int k=j+1;k<=n;k++)
                {
                    if (where[j]!=where[k]) cs=a[j]+a[k]+h; else cs=a[j]+a[k];
                    mine=min(mine,cs);maxe=max(maxe,cs);
                }
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                for (int j=1;j<=n;j++) ans[j]=where[j];
            }
        }
        printf("%d\n",minc);
        for (int i=1;i<=n;i++) printf("%d ",ans[i]);printf("\n");
    }
    else
    {
        minc=abs(a[1]+a[2]-a[n]-a[n-1]);
        for (int i=1;i<=n;i++) nowans[i]=1;
        eel=-1;
        for (int i=2;i<=n-2;i++)
        {
            maxe=max(a[n]+a[n-1],a[n]+a[i]+h);
            mine=min(a[i]+a[i+1],a[1]+a[i]+h);
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                eel=i;
            }
        }
        if (eel!=-1) for (int i=2;i<=eel;i++) nowans[i]=2;
        c=min(n,4);
        for (int i=0;i<=((1<<c)-1);i++)
        {
            memset(where,0,sizeof(where));
            for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
            mine=maxlongint;
            maxe=a[n]+a[n-1];
            for (int j=1;j<=c;j++)
                for (int k=j+1;k<=c;k++)
                    if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                    else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
            for (int j=1;j<=c;j++)
                for (int k=c+1;k<=n;k++)
                    if (where[j]!=1) maxe=max(maxe,a[j]+a[k]+h),mine=min(mine,a[j]+a[k]+h);
                                else maxe=max(maxe,a[j]+a[k]),mine=min(mine,a[j]+a[k]);
            if (maxe-mine<minc)
            {
                minc=maxe-mine;
                for (int j=1;j<=c;j++) nowans[j]=where[j];
                for (int j=c+1;j<=n;j++) nowans[j]=1;
            }
        }
        printf("%d\n",minc);
        for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
        printf("\n");
    }

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,cs,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];
pair<int,int> b[200000];

int main()
{
    //freopen("B.in","r",stdin);
    //freopen("B.out","w",stdout);
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&cs);
        b[i]=make_pair(cs,i);
    }
    sort(b+1,b+n+1);
    for (int i=1;i<=n;i++) a[i]=b[i].first;
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,4);
    for (int i=0;i<=((1<<c)-1);i++)
    {
        memset(where,0,sizeof(where));
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        for (int j=1;j<=c;j++)
            for (int k=c+1;k<=n;k++)
                if (where[j]!=1) maxe=max(maxe,a[j]+a[k]+h),mine=min(mine,a[j]+a[k]+h);
                            else maxe=max(maxe,a[j]+a[k]),mine=min(mine,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[b[j].second]=where[j];
            for (int j=c+1;j<=n;j++) nowans[b[j].second]=1;
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,4);
    for (int i=0;i<=((1<<c)-1);i++)
    {
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        for (int j=1;j<=c;j++)
            for (int k=c+1;k<=n;k++)
                if (where[j]!=where[2]) maxe=max(maxe,a[j]+a[k]+h); else maxe=max(maxe,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[j]=where[j];
            for (int j=c+1;j<=n;j++) nowans[j]=where[2];
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <functional>
#include <sstream>
#include <list>

#define maxlongint 2147483647
#define biglongint 2139062143
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PIII;

int n,h,c,minc,mine,maxe;
int a[200000],where[200000],nowans[200000];

int main()
{
    scanf("%d %d",&n,&h);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    minc=abs(a[1]+a[2]-a[n]-a[n-1]);
    for (int i=1;i<=n;i++) nowans[i]=1;
    c=min(n,5);
    for (int i=0;i<=(1<<c-1);i++)
    {
        for (int j=1;j<=c;j++) where[j]=(i>>(j-1))%2+1;
        mine=maxlongint;
        maxe=a[n]+a[n-1];
        for (int j=1;j<=c;j++)
            for (int k=j+1;k<=c;k++)
                if (where[j]!=where[k]) mine=min(mine,a[j]+a[k]+h),maxe=max(maxe,a[j]+a[k]+h);
                                   else mine=min(mine,a[j]+a[k]),maxe=max(maxe,a[j]+a[k]);
        if (maxe-mine<minc)
        {
            minc=maxe-mine;
            for (int j=1;j<=c;j++) nowans[j]=where[j];
            for (int j=c+1;j<=n;j++) nowans[j]=where[2];
        }
    }
    printf("%d\n",minc);
    for (int i=1;i<=n;i++) printf("%d ",nowans[i]);
    printf("\n");

    return 0;
}


/*                                            In The Name Of GOD                               */
//Name : Seyed Sobhan Miryoosefi
# include <iostream>
# include <iomanip>
# include <fstream>
# include <string>
# include <algorithm>
# include <vector>
# include <queue>
# include <map>
# include <set>
# include <cstring>

# define PII pair<int,int>
# define FF first
# define SS second
# define LL long long
# define PB push_back
using namespace std;
const int MAX_N=100*1000+10;
int Arr[MAX_N];
int main()
{
	ios::sync_with_stdio(false);
	int N,H;
	cin >> N >> H;
	for(int i=0;i<N;i++)
			cin >> Arr[i];
	int mn=-1;
	for(int i=0;i<N;i++)
			if(mn==-1 || Arr[mn]>Arr[i])
					mn=i;
	sort(Arr,Arr+N);
	if(N==2)
	{
		cout<<0<<endl;
		cout<<1<<" "<<1<<endl;
		return 0;
	}

	int mx1=Arr[N-1]+Arr[N-2];
	int mn1=Arr[0]+Arr[1];

	int mx2=max(mx1,Arr[N-1]+Arr[0]+H);
	int mn2=min(Arr[1]+Arr[2],Arr[1]+Arr[0]+H);

	if((mx1-mn1)<=(mx2-mn2))
	{
		cout<<mx1-mn1<<endl;
		for(int i=0;i<N;i++)
			cout<<1<<" ";
		cout<<endl;
	}
	else
	{
		cout<<mx2-mn2<<endl;
		for(int i=0;i<N;i++)
			cout<<(i==mn?2:1)<<" ";
		cout<<endl;
	}
	return 0;
}


/*                                            In The Name Of GOD                               */
//Name : Seyed Sobhan Miryoosefi
# include <iostream>
# include <iomanip>
# include <fstream>
# include <string>
# include <algorithm>
# include <vector>
# include <queue>
# include <map>
# include <set>
# include <cstring>

# define PII pair<int,int>
# define FF first
# define SS second
# define LL long long
# define PB push_back
using namespace std;
const int MAX_N=100*1000+10;
int Arr[MAX_N];
int main()
{
	ios::sync_with_stdio(false);
	int N,H;
	cin >> N >> H;
	for(int i=0;i<N;i++)
			cin >> Arr[i];
	sort(Arr,Arr+N);
	int mn=-1;
	for(int i=0;i<N;i++)
			if(mn==-1 || Arr[mn]>Arr[i])
					mn=i;
	if(N==2)
	{
		cout<<0<<endl;
		cout<<1<<" "<<1<<endl;
		return 0;
	}

	int mx1=Arr[N-1]+Arr[N-2];
	int mn1=Arr[0]+Arr[1];

	int mx2=max(mx1,Arr[N-1]+Arr[0]+H);
	int mn2=min(Arr[1]+Arr[2],Arr[1]+Arr[0]+H);

	if((mx1-mn1)<=(mx2-mn2))
	{
		cout<<mx1-mn1<<endl;
		for(int i=0;i<N;i++)
			cout<<1<<" ";
		cout<<endl;
	}
	else
	{
		cout<<mx2-mn2<<endl;
		for(int i=0;i<N;i++)
			cout<<(i==mn?2:1)<<" ";
		cout<<endl;
	}
	return 0;
}


/*                                            In The Name Of GOD                               */
//Name : Seyed Sobhan Miryoosefi
# include <iostream>
# include <iomanip>
# include <fstream>
# include <string>
# include <algorithm>
# include <vector>
# include <queue>
# include <map>
# include <set>
# include <cstring>

# define PII pair<int,int>
# define FF first
# define SS second
# define LL long long
# define PB push_back
using namespace std;
const int MAX_N=100*1000+10;
int Arr[MAX_N];
int main()
{
	ios::sync_with_stdio(false);
	int N,H;
	cin >> N >> H;
	for(int i=0;i<N;i++)
			cin >> Arr[i];
	sort(Arr,Arr+N);
	if(N==2)
	{
		cout<<0<<endl;
		cout<<1<<" "<<1<<endl;
		return 0;
	}
	int mx1=Arr[N-1]+Arr[N-2];
	int mn1=Arr[0]+Arr[1];

	int mx2=max(mx1,Arr[N-1]+Arr[0]+H);
	int mn2=min(Arr[1]+Arr[2],Arr[1]+Arr[0]+H);

	if((mx1-mn1)<=(mx2-mn2))
	{
		cout<<mx1-mn1<<endl;
		for(int i=0;i<N;i++)
			cout<<1<<" ";
		cout<<endl;
	}
	else
	{
		cout<<mx2-mn2<<endl;
		cout<<2<<" ";
		for(int i=0;i<N-1;i++)
			cout<<1<<" ";
		cout<<endl;
	}
	return 0;
}


//satyaki3794
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cassert>
#include <bitset>
#include <iomanip>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define PI (3.14159265)
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define INF (100000005)
#define SIZE (2)
#define TREESIZE (302144)
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n+1)
#define epsilon 1e-8 //add to double before casting to integer

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

#define matrix vector< vector<ll> >

matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }

    return ans;
}

matrix matpwr(matrix &a, ll p){
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;

    while(p){
        if(p&1) ans = matmul(ans, a);

        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}

ll pwr(ll base, ll p, ll mod = MOD){
    ll ans = 1;
    while(p){
        if(p & 1)   ans = (ans * base) % mod;
        base = (base * base) % mod;
        p /= 2;
    }
    return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}

ll invMod(ll n, ll mod = MOD){
    return pwr(n, mod-2);
}

int n, arr[100003];

int main()
{
    ios_base::sync_with_stdio(0);
    // freopen("input.txt", "r", stdin);

    //consider only 2 cases, in which smallest element is in same or different partition

    int h;
    cin>>n>>h;
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    sort(arr, arr+n);

    if(n == 2){
    	cout<<"0\n1 1";
    	return 0;
    }

    int ans = (arr[n-1]+arr[n-2]) - (arr[0]+arr[1]);

    //move smallest element
    int mini = min(arr[1]+arr[2], arr[0]+arr[1]+h);
    int maxi = max(arr[n-1]+arr[n-2], arr[n-1]+arr[0]+h);
    ans = min(ans, maxi-mini);

    cout<<ans<<endl;
    if(ans == maxi-mini)	cout<<"2 ";
    else	cout<<"1 ";
    for(int i=1;i<n;i++)
    	cout<<"1 ";
    return 0;
}


//satyaki3794
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cassert>
#include <bitset>
#include <iomanip>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define PI (3.14159265)
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define INF (100000005)
#define SIZE (2)
#define TREESIZE (302144)
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n+1)
#define epsilon 1e-8 //add to double before casting to integer

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

#define matrix vector< vector<ll> >

matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }

    return ans;
}

matrix matpwr(matrix &a, ll p){
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;

    while(p){
        if(p&1) ans = matmul(ans, a);

        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}

ll pwr(ll base, ll p, ll mod = MOD){
    ll ans = 1;
    while(p){
        if(p & 1)   ans = (ans * base) % mod;
        base = (base * base) % mod;
        p /= 2;
    }
    return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}

ll invMod(ll n, ll mod = MOD){
    return pwr(n, mod-2);
}

int n, arr[100003];

int main()
{
    ios_base::sync_with_stdio(0);
    // freopen("input.txt", "r", stdin);

    //consider only 2 cases, in which smallest element is in same or different partition

    int h;
    cin>>n>>h;
    for(int i=0;i<n;i++)
    	cin>>arr[i];

    int minval = *min_element(arr, arr+n);
    int pos = -1;
    for(int i=0;i<n;i++)
    	if(arr[i] == minval){
    		pos = i;	break;
    	}
    sort(arr, arr+n);

    if(n == 2){
    	cout<<"0\n1 1";
    	return 0;
    }

    int ans = (arr[n-1]+arr[n-2]) - (arr[0]+arr[1]);

    //move smallest element
    int mini = min(arr[1]+arr[2], arr[0]+arr[1]+h);
    int maxi = max(arr[n-1]+arr[n-2], arr[n-1]+arr[0]+h);
    ans = min(ans, maxi-mini);

    cout<<ans<<endl;
    for(int i=0;i<n;i++)
    	if(i != pos)
    		cout<<"1 ";
    	else{
    		if(ans == maxi-mini)	cout<<"2 ";
    		else	cout<<"1 ";
    	}
    return 0;
}


//satyaki3794
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cassert>
#include <bitset>
#include <iomanip>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define PI (3.14159265)
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define INF (100000005)
#define SIZE (2)
#define TREESIZE (302144)
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n+1)
#define epsilon 1e-8 //add to double before casting to integer

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

#define matrix vector< vector<ll> >

matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }

    return ans;
}

matrix matpwr(matrix &a, ll p){
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;

    while(p){
        if(p&1) ans = matmul(ans, a);

        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}

ll pwr(ll base, ll p, ll mod = MOD){
    ll ans = 1;
    while(p){
        if(p & 1)   ans = (ans * base) % mod;
        base = (base * base) % mod;
        p /= 2;
    }
    return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}

ll invMod(ll n, ll mod = MOD){
    return pwr(n, mod-2);
}

int n, arr[100003];

int main()
{
    ios_base::sync_with_stdio(0);
    // freopen("input.txt", "r", stdin);

    //consider only 2 cases, in which smallest element is in same or different partition

    int h;
    cin>>n>>h;
    for(int i=0;i<n;i++)
        cin>>arr[i];

    if(n == 2){
        cout<<"0\n1 1";
        return 0;
    }

    int ans = (arr[n-1]+arr[n-2]) - (arr[0]+arr[1]);

    //move smallest element
    int mini = min(arr[1]+arr[2], arr[0]+arr[1]+h);
    int maxi = max(arr[n-1]+arr[n-2], arr[n-1]+arr[0]+h);
    ans = min(ans, maxi-mini);

    cout<<ans<<endl;
    if(ans == maxi-mini)    cout<<"2 ";
    else    cout<<"1 ";
    for(int i=1;i<n;i++)
        cout<<"1 ";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define mod 1000000007
#define N 100005

pair<int,int> a[N];

int main()
{
    int n,h,i;

    scanf("%d%d",&n,&h);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i].first);
        a[i].second = i;
    }
    sort(a,a+n);
    int t1,t2;

    if(n==2)
        printf("1 1");
    else
    {
        int x = a[n-1].first+a[n-2].first;
        int y = a[0].first+a[1].first;

        t1 = x-y;

        y+=h;
        t2 = max(x,y)-min(x,y);

        printf("%d\n",min(t1,t2));
        if(t1<t2)
            for(i=0;i<n;i++)
                printf("1 ");
        else
            for(i=0;i<n;i++)
                if(a[0].second==i)
                    printf("1 ");
                else
                    printf("2 ");
    }
    return 0;
}