#include <bits/stdc++.h>
using namespace std;
bool cust1(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
  return a.second < b.second;
}
bool cust2(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
  return a.first < b.first;
}
class CompareDist {
 public:
  bool operator()(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
    return a.first > b.first;
  }
};
int main() {
  int64_t n, m, d, i;
  cin >> n >> m >> d;
  vector<pair<int64_t, int64_t> > arr(n);
  for (i = 0; i < n; i++) {
    cin >> arr[i].second;
    arr[i].first = i;
  }
  sort(arr.begin(), arr.begin() + arr.size(), cust1);
  vector<pair<int64_t, int64_t> > answer;
  int64_t current_day = 1;
  priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t> >,
                 CompareDist>
      pq;
  pq.push(make_pair(arr[0].second + d, current_day));
  answer.push_back(make_pair(arr[0].first, current_day));
  current_day = current_day + 1;
  for (i = 1; i < n; i++) {
    pair<int64_t, int64_t> temp = pq.top();
    if (arr[i].second > temp.first) {
      pq.pop();
      answer.push_back(make_pair(arr[i].first, temp.second));
      pq.push(make_pair(arr[i].second + d, temp.second));
    } else {
      pq.push(make_pair(arr[i].second + d, current_day));
      answer.push_back(make_pair(arr[i].first, current_day));
      current_day++;
    }
  }
  sort(answer.begin(), answer.begin() + arr.size(), cust2);
  cout << current_day - 1 << "\n";
  for (i = 0; i < answer.size(); i++) cout << answer[i].second << " ";
  return 0;
}
