#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, d, x;
  cin >> n >> m >> d;
  long long int a[n];
  unordered_map<long long int, long long int> days;
  set<long long int> myset;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    myset.insert(a[i]);
  }
  long long int val = 1;
  while (myset.size()) {
    auto itr = myset.begin();
    while (itr != myset.end()) {
      days[*itr] = val;
      long long int temp = *itr;
      myset.erase(itr);
      itr = myset.upper_bound((temp + d));
    }
    val++;
  }
  cout << val - 1 << '\n';
  for (long long int i = 0; i < n; i++) cout << days[a[i]] << ' ';
  return 0;
}
