#include <bits/stdc++.h>
#pragma optimize("Ofast")
using namespace std;
using ll = long long;
const int N = 3e5 + 5;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, d;
  cin >> n >> m >> d;
  set<int> s;
  map<int, int> index;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    index[x] = i;
    s.insert(x);
  }
  int day = 1;
  vector<int> ans(n), toErase;
  while (s.size()) {
    auto it = s.begin();
    while (it != s.end()) {
      ans[index[*it]] = day;
      toErase.push_back(*it);
      it = s.lower_bound(*it + d + 1);
    }
    ++day;
    for (auto itr : toErase) s.erase(itr);
    toErase.clear();
  }
  cout << day - 1 << "\n";
  for (auto it : ans) cout << it << ' ';
  return 0;
}
