A8026 | Presents
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The Hedgehog likes to give presents to his friend, but no less he likes to receive them.
Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he choose, how large should it be?
In order to get to know this, the Hedgehog asks you to write him a program that will count the estimated number of presents that he will receive during the following $N$ days. Besides, he is guided by the principle:
- on each holiday day the Hedgehog will necessarily receive a present,
- he receives presents at least every $K$ days (i.e., if he received a present on the $i$ -th day, he will receive the next present no later than on the $i+K$ -th day).
For the given $N$ and $K$ , as well as the list of holidays among the following $N$ days count the minimal number of presents that could be given to the Hedgehog. The number of today's day is zero, and you should regard today's present as already given (i.e., you shouldn't count it in the answer).
Having received another present today, the Hedgehog suddenly understood that he has no place to put it as there was no room left on the special shelf in the cupboard. He will have to choose another shelf, but which one should he choose, how large should it be?
In order to get to know this, the Hedgehog asks you to write him a program that will count the estimated number of presents that he will receive during the following $N$ days. Besides, he is guided by the principle:
- on each holiday day the Hedgehog will necessarily receive a present,
- he receives presents at least every $K$ days (i.e., if he received a present on the $i$ -th day, he will receive the next present no later than on the $i+K$ -th day).
For the given $N$ and $K$ , as well as the list of holidays among the following $N$ days count the minimal number of presents that could be given to the Hedgehog. The number of today's day is zero, and you should regard today's present as already given (i.e., you shouldn't count it in the answer).
输入格式
The first line contains integers $N$ and $K$ ( $1<=N<=365$ , $1<=K<=N$ ).
The second line contains a number $C$ which represents the number of holidays ( $0<=C<=N$ ). Then in the same line follow $C$ numbers ranging from $1$ to $N$ which are the numbers of holiday days. The numbers are given in the increasing order, without repeating numbers among them.
The second line contains a number $C$ which represents the number of holidays ( $0<=C<=N$ ). Then in the same line follow $C$ numbers ranging from $1$ to $N$ which are the numbers of holiday days. The numbers are given in the increasing order, without repeating numbers among them.
输出格式
Print a single number — the minimal number of presents the Hedgehog will receive over the following $N$ days.
输入输出样例
输入 #1
5 2 1 3
输出 #1
3
输入 #2
10 1 3 6 7 8
输出 #2
10
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted