Problem:
Score : 300 points

Problem Statement

Every day, N passengers arrive at Takahashi Airport.
The i-th passenger arrives at time T_i.

Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers.
Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport.
Also, a passenger will get angry if he/she is still unable to take a bus K units of time after the arrival of the airplane.
For that reason, it is necessary to arrange buses so that the i-th passenger can take a bus departing at time between T_i and T_i + K (inclusive).

When setting the departure times for buses under this condition, find the minimum required number of buses.
Here, the departure time for each bus does not need to be an integer, and there may be multiple buses that depart at the same time.

Constraints

2 \leq N \leq 100000

1 \leq C \leq 10^9

1 \leq K \leq 10^9

1 \leq T_i \leq 10^9

C, K and T_i are integers.

Input

The input is given from Standard Input in the following format:

N C K
T_1
T_2
:
T_N

Output

Print the minimum required number of buses.

Sample Input 1

5 3 5
1
2
3
6
12

Sample Output 1

3

For example, the following three buses are enough:

A bus departing at time 4.5, that carries the passengers arriving at time 2 and 3.

A bus departing at time 6, that carries the passengers arriving at time 1 and 6.

A bus departing at time 12, that carries the passenger arriving at time 12.

Sample Input 2

6 3 3
7
6
2
8
10
6

Sample Output 2

3

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long int MOD = (int)1e9 + 7;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
    for (T &t : v) s >> t;
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    for (const T &t : v) s << t << endl;
    return s;
}
template<typename T> T min(const vector<T>& v) {return *min_element(v.begin(), v.end());}
template<typename T> T max(const vector<T>& v) {return *max_element(v.begin(), v.end());}
template<typename T> int min_element(vector<T>& v) {return min_element(v.begin(), v.end()) - v.begin();}
template<typename T> int max_element(vector<T>& v) {return max_element(v.begin(), v.end()) - v.begin();}
template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}
template<typename T> void greatersort(vector<T>& v) {sort(v.begin(), v.end(), greater<>());}
template<typename T, typename Function> void sort(vector<T>& v, Function func) {sort(v.begin(), v.end(), func);}
template<typename T> void rsort(vector<T>& v) {sort(v.rbegin(), v.rend());}
template<typename T> void reverse(vector<T>& v) {reverse(v.begin(), v.end());}
template<typename T> void unique(vector<T>& v) {v.erase(unique(v.begin(), v.end()), v.end());}
template<typename T> void nth_element(vector<T>& v, int n) {nth_element(v.begin(), v.begin() + n, v.end());}
template<typename T> bool next_permutation(vector<T>& v) {return next_permutation(v.begin(), v.end());}
template<typename T> int find(vector<T>& v, T t) {return find(v.begin(), v.end(), t) - v.begin();}
template<typename T> int in(vector<T> v, T t) {return find(v, t) != int(v.size());}
template<typename T> int lower_bound(vector<T>& v, T t) {return lower_bound(v.begin(), v.end(), t) - v.begin();}
template<typename T> int upper_bound(vector<T>& v, T t) {return upper_bound(v.begin(), v.end(), t) - v.begin();}
template<typename T> T accumulate(const vector<T>& v, function<T(T, T)> func = plus<T>()) {return accumulate(v.begin(), v.end(), T(), func);}
template<typename T> void adjacent_difference(vector<T>& v) {adjacent_difference(v.begin(), v.end(), v.begin());}
template<typename T> void adjacent_difference(vector<T>& v, vector<T>& u) {adjacent_difference(v.begin(), v.end(), u.begin());}
template<typename T> vector<T> partial_sum(const vector<T>& v) {
    vector<T> u(v.size());
    partial_sum(v.begin(), v.end(), u.begin());
    return u;
}\
template<typename T> T inner_product(vector<T>& v, vector<T>& u) {return inner_product(v.begin(), v.end(), u.begin(), T(0));}
template<typename T> int count(const vector<T>& v, T t) {return count(v.begin(), v.end(), t);}
template<typename T, typename Function> int count_if(const vector<T>& v, Function func) {return count_if(v.begin(), v.end(), func);}
template<typename T, typename Function> void remove_if(vector<T>& v, Function func) {v.erase(remove_if(v.begin(), v.end(), func), v.end());}
template<typename T, typename Function> bool all_of(vector<T> v, Function func) {return all_of(v.begin(), v.end(), func);}
template<typename T, typename Function> bool any_of(vector<T> v, Function func) {return any_of(v.begin(), v.end(), func);}
template<typename T, typename Function> bool none_of(vector<T> v, Function func) {return none_of(v.begin(), v.end(), func);}
template<typename T> vector<T> subvector(vector<T>& v, int a, int b) {return vector<T>(v.begin() + a, v.begin() + b);}
template<typename T> int kinds(const vector<T>& v) {return set<T>(v.begin(), v.end()).size();}
template<typename T> map<T, int> count_kinds(const vector<T>& v) {
    map<T, int> res;
    for (const auto& i : v) ++res[i];
    return res;
}
template<typename T> void iota(vector<T>& v, T t = 0) {iota(v.begin(), v.end(), t);}
template<typename T> bool is_sorted(const vector<T>& v) {return is_sorted(v.begin(), v.end());}
int plusVector(vector<int>& v, int n) {int r = 0; for (int i = 0; i < n; ++i) {r += v[i];} return r;}
void yesno(bool b) {if (b) {cout << "yes" << endl;} else {cout << "no" << endl;}}
void YesNo(bool b) {if (b) {cout << "Yes" << endl;} else {cout << "No" << endl;}}
void YESNO(bool b) {if (b) {cout << "YES" << endl;} else {cout << "NO" << endl;}}
long addMOD(long a, long b) {return (a + b) % MOD;}
long subMOD(long a, long b) {return (a + MOD - b) % MOD;}
long mulMOD(long a, long b) {return ((a % MOD) * (b % MOD)) % MOD;}
long long invMOD(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
double PI = 3.1415926535897932384626433832795;
typedef long long int ll;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, C, K;
    cin >> N >> C >> K;
    vector<pair<int, int>> T(N);
    for (int i = 0; i < N; ++i) {
        cin >> T[i].first;
        T[i].second = T[i].first + K;
    }
    sort(T.begin(), T.end());
    int answer = 1;
    int busTime = T[0].second, busRemain = C;
    bool check = true;
    for (int i = 0; i < N; ++i) {
        if (T[i].first <= busTime && busTime <= T[i].second && busRemain != 0) {
            check = true;
            --busRemain;
            busTime = T[i].second;
        } else {
            check = false;
            busTime = T[i].second;
            busRemain = C;
            ++answer;
        }
    }
    if (check) ++answer;
    cout << answer << endl;
}