A11386 | Alarm Clock
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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 minimal number of alarm clocks that Vitalya should turn off to sleep all next day long.
输入输出样例
输入 #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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted