#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = INT_MAX;
const long long mod = 1e9 + 7;
const int pi = acos(-1);
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 2e5 + 5;
set<pair<int, int> > second;
int ans[N];
int main() {
  int n, m, d;
  cin >> n >> m >> d;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    second.insert({a, i});
  }
  int cur = 1;
  while (!second.empty()) {
    pair<int, int> v = *second.begin();
    ans[v.second] = cur;
    second.erase(v);
    while (1) {
      if (second.lower_bound(make_pair(v.first + d + 1, 0)) == second.end())
        break;
      pair<int, int> to = *second.lower_bound(make_pair(v.first + d + 1, 0));
      ans[to.second] = cur;
      v = to;
      second.erase(to);
    }
    cur++;
  }
  cout << cur - 1 << endl;
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
