E - Alarm Clock (尺取法)

题目链接:https://cn.vjudge.net/problem/CodeForces-898D 

Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer ai — number of minute after midnight in which it rings. Every alarm clock begins ringing at the beginning of the minute and rings during whole minute.

Vitalya will definitely wake up if during some m consecutive minutes at least kalarm clocks will begin ringing. Pay attention that Vitalya considers only alarm clocks which begin ringing during given period of time. He doesn't consider alarm clocks which started ringing before given period of time and continues ringing during given period of time.

Vitalya is so tired that he wants to sleep all day long and not to wake up. Find out minimal number of alarm clocks Vitalya should turn off to sleep all next day. Now all alarm clocks are turned on.

Input

First line contains three integers nm and k (1 ≤ k ≤ n ≤ 2·105, 1 ≤ m ≤ 106) — number of alarm clocks, and conditions of Vitalya's waking up.

Second line contains sequence of distinct integers a1, a2, ..., an (1 ≤ ai ≤ 106) in which ai equals minute on which i-th alarm clock will ring. Numbers are given in arbitrary order. Vitalya lives in a Berland in which day lasts for 106 minutes.

Output

Output minimal number of alarm clocks that Vitalya should turn off to sleep all next day long.

Examples

Input

3 3 2
3 5 1

Output

1

Input

5 10 3
12 8 18 25 1

Output

0

Input

7 7 2
7 3 4 1 6 5 2

Output

6

Input

2 2 2
1 3

Output

0

Note

In first example Vitalya should turn off first alarm clock which rings at minute 3.

In second example Vitalya shouldn't turn off any alarm clock because there are no interval of 10 consequence minutes in which 3 alarm clocks will ring.

In third example Vitalya should turn off any 6 alarm clocks.

题意:给n个时间点ai-an,表示闹钟是在这个时间点响的,m表示时间段,k表示K个闹钟,在m这个时间段里有k个闹钟响,就能把他吵醒,问,最少关了多少个闹钟,可以让他不被闹钟吵醒,

具体看代码就能理解,用到的知识点是尺取法

#include 
#include
#include
#include
#include
using namespace std;
const int N=1000001;
int a[N];
int b[N];
int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0; i

 

你可能感兴趣的:(VJ,懂我)