#include <bits/stdc++.h>   using namespace std;   set<int> s;   map<int, int> mm;   int a[500005];   int main() {     int n, m, d;     cin >> n >> m >> d;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       s.insert(k);       a[i] = k;     }     set<int>::iterator it1, it2, it3;     int sum = 0;     for (it1 = s.begin(); it1 != s.end(); it1++) {       sum++;       mm[*it1] = sum;       it2 = it1;       while (s.upper_bound((*it2) + d) != s.end()) {         it3 = s.upper_bound((*it2) + d);         mm[*it3] = sum;         it2 = it3;         s.erase(it3);       }     }     cout << sum << endl;     for (int i = 0; i < n; i++) {       cout << mm[a[i]] <<    ;     }     cout << endl;   }   