#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LNF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;
const double EPS = 1e-8;
const long double EUL = 2.71828182845904523536;
const long double PII = 3.14159265358979323846;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, d;
  while (cin >> n >> m >> d) {
    int coffee[n];
    int ans[n];
    set<pair<int, int> > timeline;
    for (int i = 0; i < n; i++) {
      cin >> coffee[i];
      timeline.insert({coffee[i], i});
    }
    int day = 0;
    while (!timeline.empty()) {
      day++;
      int x = timeline.begin()->second;
      ans[x] = day;
      timeline.erase(timeline.begin());
      while (1) {
        auto it = timeline.lower_bound({coffee[x] + d + 1, -1});
        if (it == timeline.end()) break;
        x = it->second;
        ans[x] = day;
        timeline.erase(it);
      }
    }
    cout << day << endl;
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  cerr << "Time : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
