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 Rust (1.15.1) (judge verdict: Accepted)

use std::str::FromStr;

trait Readable: std::marker::Sized {
    fn read(s: &str) -> Self;
    fn read_line(s: String) -> Self {
        Self::read(&s)
    }
}

impl Readable for String {
    fn read(s: &str) -> String { s.to_string() }
    fn read_line(s: String) -> String { s }
}

impl Readable for f64 {
    fn read(s: &str) -> f64 { f64::from_str(s).expect("cannot parse f64") }
}

impl Readable for isize {
    fn read(s: &str) -> isize { isize::from_str(s).expect("cannot parse isize") }
}

impl Readable for i8 {
    fn read(s: &str) -> i8 { i8::from_str(s).expect("cannot parse i8") }
}

impl Readable for i16 {
    fn read(s: &str) -> i16 { i16::from_str(s).expect("cannot parse i16") }
}

impl Readable for i32 {
    fn read(s: &str) -> i32 { i32::from_str(s).expect("cannot parse i32") }
}

impl Readable for i64 {
    fn read(s: &str) -> i64 { i64::from_str(s).expect("cannot parse i64") }
}

impl Readable for usize {
    fn read(s: &str) -> usize { usize::from_str(s).expect("cannot parse usize") }
}

impl Readable for u8 {
    fn read(s: &str) -> u8 { u8::from_str(s).expect("cannot parse u8") }
}

impl Readable for u16 {
    fn read(s: &str) -> u16 { u16::from_str(s).expect("cannot parse u16") }
}

impl Readable for u32 {
    fn read(s: &str) -> u32 { u32::from_str(s).expect("cannot parse u32") }
}

impl Readable for u64 {
    fn read(s: &str) -> u64 { u64::from_str(s).expect("cannot parse u64") }
}

impl<T1: Readable, T2: Readable> Readable for (T1, T2) {
    fn read(s: &str) -> (T1, T2) {
        let items: Vec<&str> = s.split(' ').collect();
        assert!(items.len() == 2);
        (T1::read(items[0]), T2::read(items[1]))
    }
}

impl <T1: Readable, T2: Readable, T3: Readable> Readable for (T1, T2, T3) {
    fn read(s: &str) -> Self {
        let items: Vec<&str> = s.split(' ').collect();
        assert!(items.len() == 3);
        (T1::read(items[0]), T2::read(items[1]), T3::read(items[2]))
    }
}

#[allow(dead_code)]
fn read<T: Readable>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    let last = line.pop();
    match last {
        Some(ch) if ch != '\n' => line.push(ch),
        _ => ()
    }

    T::read_line(line)
}

#[allow(dead_code)]
fn read_lines<T: Readable>() -> Vec<T> {
    use std::io::{stdin, BufRead};
    let mut v = Vec::new();
    let stdin = stdin();
    for line in stdin.lock().lines() {
        v.push(T::read_line(line.unwrap()));
    }
    v
}

fn main() {
    let (_, capacity, persistence): (u32, u32, u32) = read();
    let mut ts: Vec<u32> = read_lines();
    ts.sort();
    let mut i = 0;
    let mut bus_count = 0;

    while i < ts.len() {
        bus_count += 1;
        let limit = ts[i] + persistence;

        i += 1;
        let mut boarded = 1;
        while i < ts.len() && ts[i] <= limit && boarded < capacity {
            i += 1;
            boarded += 1;
        }
    }

    println!("{}", bus_count);
}