A12104 | Cashier
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has already memorized $n$ regular customers, the $i$ -th of which comes after $t_{i}$ minutes after the beginning of the day, and his service consumes $l_{i}$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer.
Vasya is a bit lazy, so he likes taking smoke breaks for $a$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
Vasya is a bit lazy, so he likes taking smoke breaks for $a$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
输入格式
The first line contains three integers $n$ , $L$ and $a$ ( $0 \le n \le 10^{5}$ , $1 \le L \le 10^{9}$ , $1 \le a \le L$ ).
The $i$ -th of the next $n$ lines contains two integers $t_{i}$ and $l_{i}$ ( $0 \le t_{i} \le L - 1$ , $1 \le l_{i} \le L$ ). It is guaranteed that $t_{i} + l_{i} \le t_{i + 1}$ and $t_{n} + l_{n} \le L$ .
The $i$ -th of the next $n$ lines contains two integers $t_{i}$ and $l_{i}$ ( $0 \le t_{i} \le L - 1$ , $1 \le l_{i} \le L$ ). It is guaranteed that $t_{i} + l_{i} \le t_{i + 1}$ and $t_{n} + l_{n} \le L$ .
输出格式
Output one integer — the maximum number of breaks.
输入输出样例
输入 #1
2 11 3 0 1 1 1
输出 #1
3
输入 #2
0 5 2
输出 #2
2
输入 #3
1 3 2 1 2
输出 #3
0
In the first sample Vasya can take $3$ breaks starting after $2$ , $5$ and $8$ minutes after the beginning of the day.
In the second sample Vasya can take $2$ breaks starting after $0$ and $2$ minutes after the beginning of the day.
In the third sample Vasya can't take any breaks.
In the second sample Vasya can take $2$ breaks starting after $0$ and $2$ minutes after the beginning of the day.
In the third sample Vasya can't take any breaks.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted