#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) { return (b == 0) ? a : GCD(b, a % b); }
long long oo = 1e18;
long long const M = 1e9 + 7, N = 3e5 + 9;
int n, m, d;
string s = "";
int ans = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> d;
  vector<int> v;
  set<int> s;
  map<int, int> mb;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    s.insert(x);
    v.push_back(x);
  }
  int day = 1, cofe = 0;
  while (s.size()) {
    if (s.lower_bound(cofe) != s.end()) {
      cofe = *s.lower_bound(cofe);
      s.erase(s.lower_bound(cofe));
      mb[cofe] = day;
      cofe += d + 1;
    } else {
      cofe = 0;
      day++;
    }
  }
  cout << day << endl;
  for (int i = 0; i < n; i++) {
    cout << mb[v[i]] << " ";
  }
  return 0;
}
