#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433;
const long long M = 1e9 + 7;
multiset<long long> ms;
map<long long, long long> mp;
long long a[200100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, d, x, mmax = 0, t = 0, s = 0;
  cin >> n >> m >> d;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    ms.insert(a[i]);
    mmax = max(mmax, a[i]);
  }
  while (ms.size() != 0) {
    s++;
    mp[*ms.begin()] = s;
    t = *ms.begin() + d + 1;
    ms.erase(*ms.begin());
    while (true) {
      auto p = ms.lower_bound(t);
      if (p == ms.end()) break;
      x = *ms.lower_bound(t);
      t = x + d + 1;
      mp[x] = s;
      ms.erase(x);
    }
  }
  cout << s << endl;
  for (long long i = 0; i < n; i++) cout << mp[a[i]] << " ";
}
