Codeforces Round 451 (Div. 2)
D
Alarm Clock
Codeforces
1600
原题
← CE →
翻译中…

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 $*a*_{*i*}$ — 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 $*k*$ alarm 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 $*n*$, $*m*$ and $*k*$ ($1 ≤ *k* ≤ *n* ≤ 2·10^{5}$, $1 ≤ *m* ≤ 10^{6}$) — number of alarm clocks, and conditions of Vitalya's waking up.

翻译中…

Second line contains sequence of distinct integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{6}$) in which $*a*_{*i*}$ 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 $10^{6}$ minutes.

翻译中…

Output

翻译中…

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

翻译中…

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.

翻译中…

样例

Input #1
3 3 2
3 5 1
Output #1
1
InputCopy OutputCopy
Input #2
5 10 3
12 8 18 25 1
Output #2
0
InputCopy OutputCopy
Input #3
7 7 2
7 3 4 1 6 5 2
Output #3
6
InputCopy OutputCopy
Input #4
2 2 2
1 3
Output #4
0
InputCopy OutputCopy
题目信息
题号
898D
时间限制
2 s
内存限制
256 MB
标签
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。