Codeforces Round #514 (Div. 2).A. Cashier

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

3

input

0 5 2

output

2

input

1 3 2
1 2

output

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.

 

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M(a) memset(a,0,sizeof(a))
#define rep(i,a) for(int i=1;i<=a;i++)

struct node{
    int arr;
    int las;
}b[100010];


bool cmp(node a,node b){
    return a.arr<b.arr;
}

int main()
{
    int n,m,L,a;
    while(cin>>n>>L>>a)
    {
        memset(b,0,sizeof(b));
        for(int i=0;i<n;i++){
            cin>>b[i].arr;
            cin>>b[i].las;
        }
        sort(b,b+n,cmp);
        int ans=0;
        ans+=b[0].arr/a;
        for(int i=1;i<n;i++){
            ans+=((b[i].arr-(b[i-1].las+b[i-1].arr))/a);
        }
        ans+=((L-(b[n-1].arr+b[n-1].las))/a);
        cout<<ans<<endl;
    }
    return 0;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值