#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> ans(n, 0);
  map<int, int> s;
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    s[temp] = i;
  }
  int look = 0, current = 1;
  while (s.empty() == false) {
    look = 0;
    while (1) {
      auto it = s.lower_bound(look);
      if (it != s.end()) {
        ans[it->second] = current;
        look = it->first + d + 1;
        s.erase(it->first);
      } else {
        current++;
        break;
      }
    }
  }
  cout << current - 1 << endl;
  for (auto it : ans) cout << it << " ";
  return 0;
}
