#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  int a[n + 1];
  vector<pair<int, int>> p, p1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    p.push_back({a[i], i});
  }
  sort(p.begin(), p.end());
  sort(a + 1, a + n + 1);
  int x = 1;
  d = d + 1;
  int b[n + 1];
  b[1] = 1;
  int j = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] - a[j] >= d) {
      b[i] = b[j];
      j++;
    } else {
      x++;
      b[i] = x;
    }
  }
  for (int i = 1; i <= n; i++) {
    auto it = p[i - 1];
    p1.push_back({it.second, b[i]});
  }
  sort(p1.begin(), p1.end());
  cout << x << endl;
  for (int i = 0; i < n; i++) {
    auto it = p1[i];
    cout << it.second << " ";
  }
}
