#include <bits/stdc++.h>
using namespace std;
int n, m, d, days[223456], mx;
pair<int, int> a[223456];
queue<pair<int, int> > k;
bool cmp(int a, int b) { return a > b; }
priority_queue<int, vector<int>, decltype(&cmp)> zero(cmp);
int main() {
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a, a + n);
  zero.push(1);
  int mx = 1;
  for (int i = 0; i < n; i++) {
    while (!k.empty() && k.front().first + d < a[i].first) {
      zero.push(days[k.front().second]);
      k.pop();
    }
    int p = zero.top();
    zero.pop();
    if (zero.empty()) {
      mx++;
      zero.push(mx);
    }
    days[a[i].second] = p;
    k.push(a[i]);
  }
  cout << mx - 1 << endl;
  for (int i = 0; i < n; i++) {
    cout << days[i] << " ";
  }
  cout << endl;
  return 0;
}
