#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b, long long p = (int)(1e9 + 7)) {
  return ((a % p) * (b % p)) % p;
}
long long add(long long a, long long b, long long p = (int)(1e9 + 7)) {
  return (a % p + b % p) % p;
}
long long fpow(long long n, long long k, long long p = (int)(1e9 + 7)) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
long long inv(long long a, long long p = (int)(1e9 + 7)) {
  return fpow(a, p - 2, p);
}
bool sa(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool fd(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
bool sd(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, d, sum = 0, c = 0, q = 0, a;
  unordered_map<long long, long long> vis;
  cin >> n >> m >> d;
  set<long long> s;
  long long b[200005] = {0};
  for (int i = 0; i < n; i++) {
    cin >> a;
    s.insert(a);
    b[i] = a;
  }
  long long p = 0;
  while (!s.empty()) {
    auto it = s.begin();
    if (vis[*it] == 0) {
      sum = *it;
      p++;
      while (sum <= m) {
        if (vis[sum] == 0) {
          vis[sum] = p;
          q = p;
          s.erase(sum);
        }
        auto it1 = s.lower_bound(sum + d + 1);
        if (it1 == s.end()) break;
        sum = *it1;
      }
    }
  }
  sum = 0;
  cout << q << "\n";
  for (int i = 0; i < n; i++) {
    cout << vis[b[i]] << " ";
  }
  return 0;
}
