CF1059A.Cashier

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has recently got a job as a cashier at a local store. His day at work is LL minutes long. Vasya has already memorized nn regular customers, the ii-th of which comes after tit_{i} minutes after the beginning of the day, and his service consumes lil_{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 aa 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?

瓦西娅最近在当地一家商店找到了一份收银员的工作。他每天的工作时长为 LL 分钟。瓦西娅已经记住了 nn 位常客,其中第 ii 位顾客在一天开始后 tit_{i} 分钟到达,服务该顾客需要 lil_{i} 分钟。题目保证:在瓦西娅服务某位顾客期间,不会有其他顾客到达。

瓦西娅有点懒,因此喜欢每次抽 aa 分钟的烟休息。这些休息可以连续进行,但瓦西娅必须在所有需要服务常客的时间段内始终在岗,否则可能会被某位顾客举报给老板。那么,瓦西娅在当天最多能休息多少次?

输入格式

The first line contains three integers nn, LL and aa (0≤n≤1050 \le n \le 10^{5}, 1≤L≤1091 \le L \le 10^{9}, 1≤a≤L1 \le a \le L).

The ii-th of the next nn lines contains two integers tit_{i} and lil_{i} (0≤ti≤L−10 \le t_{i} \le L - 1, 1≤li≤L1 \le l_{i} \le L). It is guaranteed that ti+li≤ti+1t_{i} + l_{i} \le t_{i + 1} and tn+ln≤Lt_{n} + l_{n} \le L.

第一行包含三个整数 nn、LL 和 aa(0≤n≤1050 \le n \le 10^{5},1≤L≤1091 \le L \le 10^{9},1≤a≤L1 \le a \le L)。

接下来的 nn 行中,第 ii 行包含两个整数 tit_{i} 和 lil_{i}(0≤ti≤L−10 \le t_{i} \le L - 1,1≤li≤L1 \le l_{i} \le L)。保证 ti+li≤ti+1t_{i} + l_{i} \le t_{i + 1} 且 tn+ln≤Lt_{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 33 breaks starting after 22, 55 and 88 minutes after the beginning of the day.

In the second sample Vasya can take 22 breaks starting after 00 and 22 minutes after the beginning of the day.

In the third sample Vasya can't take any breaks.

在第一个样例中,瓦西娅可以在一天开始后的第 22、55 和 88 分钟之后各休息一次,共休息 33 次。

在第二个样例中,瓦西娅可以在一天开始后的第 00 和 22 分钟之后各休息一次,共休息 22 次。

在第三个样例中,瓦西娅无法进行任何休息。

输入解题思路,AI测评打分。不知道怎么写?

首页