CF898D.Alarm Clock
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
每天晚上,维塔利娅会设置 n 个闹钟,以便第二天早上醒来。每个闹钟恰好响铃一分钟,由一个整数 ai 表征——即该闹钟在午夜之后第 ai 分钟开始响铃。每个闹钟在该分钟的起始时刻开始响铃,并持续整分钟。
如果在某段连续 m 分钟的时间内,至少有 k 个闹钟开始响铃,那么维塔利娅一定会被叫醒。请注意:维塔利娅只考虑在给定时间段内开始响铃的闹钟;他不考虑那些在该时间段开始之前就已开始响铃、并持续响铃至该时间段内的闹钟。
维塔利娅实在太累了,他想一整天都睡觉、完全不醒来。请找出维塔利娅需要关闭的最少闹钟数量,才能保证他第二天一整天都不会被叫醒。目前所有闹钟均处于开启状态。
输入格式
First line contains three integers n, m 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 _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 106) 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 106 minutes.
第一行包含三个整数 n、m 和 k(1 ≤ k ≤ n ≤ 2⋅105,1 ≤ m ≤ 106)——分别表示闹钟的数量,以及 Vitalya 醒来的条件。
第二行包含一个由 n 个互不相同的整数 a1, a2, ..., an(1 ≤ ai ≤ 106)组成的序列,其中 ai 表示第 i 个闹钟将在第几分钟响起。这些数字以任意顺序给出。Vitalya 生活在 Berland,那里的一天持续 106 分钟。
输出格式
Output minimal number of alarm clocks that Vitalya should turn off to sleep all next day long.
输出 Vitalya 为确保第二天一整天都能睡觉而需要关闭的闹钟的最少数量。
输入输出样例
输入#1
3 3 2 3 5 1
输出#1
1
输入#2
5 10 3 12 8 18 25 1
输出#2
0
输入#3
7 7 2 7 3 4 1 6 5 2
输出#3
6
输入#4
2 2 2 1 3
输出#4
0
说明/提示
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.
在第一个例子中,维塔利娅应关闭在第 3 分钟响起的第一个闹钟。
在第二个例子中,维塔利娅不应关闭任何闹钟,因为在任意连续 10 分钟的时间段内,都没有 3 个闹钟会响起。
在第三个例子中,维塔利娅应关闭任意 6 个闹钟。
输入解题思路,AI测评打分。不知道怎么写?