A. Cashier

滴答滴答---题目链接

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 titi minutes after the beginning of the day, and his service consumes lili 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?

Input

The first line contains three integers nn, LL and aa (0≤n≤1050≤n≤105, 1≤L≤1091≤L≤109, 1≤a≤L1≤a≤L).

The ii-th of the next nn lines contains two integers titi and lili (0≤ti≤L−10≤ti≤L−1, 1≤li≤L1≤li≤L). It is guaranteed that ti+li≤ti+1ti+li≤ti+1 and tn+ln≤Ltn+ln≤L.

Output

Output one integer  — the maximum number of breaks.

Examples

input

Copy

2 11 3
0 1
1 1

output

Copy

3

input

Copy

0 5 2

output

Copy

2

input

Copy

1 3 2
1 2

output

Copy

0

Note

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.

题意翻译

定义一天的长度为LL,每次休息的时间为aa,有nn个客人,t_iti​表示他在这一天到来的时间,l_ili​表示他到来以后持续占用的时间。保证t_i+l_i<=t_{i+1}ti​+li​<=ti+1​。问最多能休息的次数。

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,p;
    cin>>n>>t>>p;
    int l=0,k=0;
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        l+=(x-k)/p;
        k=x+y;
    }
    t=t-k;
      l+=t/p;
    cout<<l<<endl;

}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值