func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Node {     int v, index;   } a[100005];   int n, h, big, small, tmp, diff, num;   int ans[100005];   int cmp(const void *i, const void *j) {     Node x = *(Node *)i;     Node y = *(Node *)j;     if (x.v == y.v) {       return x.index > y.index ? 1 : -1;     } else {       return x.v > y.v ? 1 : -1;     }   }   int main() {     while (scanf(  %d %d , &n, &h) != EOF) {       for (int i = 0; i < n; i++) {         scanf(  %d , &a[i].v);         a[i].index = i;       }       qsort(a, n, sizeof(a[0]), cmp);       num = 0, diff = (a[n - 1].v + a[n - 2].v) - (a[0].v + a[1].v);       for (int i = 1; i < n; i++) {         small = a[0].v + a[1].v + h;         if (i >= 2 && small > a[1].v + a[2].v) small = a[1].v + a[2].v;         if (i != n - 1 && small > a[0].v + a[i + 1].v)           small = a[0].v + a[i + 1].v;         if (i == n - 1)           big = a[i].v + a[0].v + h;         else           big = a[n - 1].v + a[i].v + h;         if (big < a[n - 1].v + a[n - 2].v) big = a[n - 1].v + a[n - 2].v;         if (diff > big - small) {           diff = big - small;           num = i;         }       }       fill(ans, ans + n, 1);       for (int i = 1; i <= num; i++) ans[a[i].index] = 2;       printf( %d n , diff);       for (int i = 0; i < n; i++) printf( %d%c , ans[i], i == n - 1 ?   n  :    );     }     return 0;   }   