Cashier Codeforces 1059A

                                                                  Cashier

time limit per test :      2 seconds            

 

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

Input

The first line contains three integers n, L and a (0≤n≤105, 1≤L≤109, 1≤a≤L).

The i-th of the next n lines contains two integers ti and li (0≤ti≤L−1, 1≤li≤L). It is guaranteed that ti+li≤ti+1 and tn+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 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.

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define eps 1e-9
#define MAXN 1e5+10
struct A
{
    int start,endd;
}a[100100];
bool cmp(A a,A b)
{
    return a.start<b.start;
}
int main()
{
    int n,L,u;
    cin>>n>>L>>u;
    int i,j,k;
    for(i=0;i<n;i++)
    {
        int t;
        cin>>a[i].start>>t;
        a[i].endd=a[i].start+t;
    }

    sort(a,a+n,cmp);
    k=a[0].start;
    int ans=0;
    ans+=k/u;
    k=L-a[n-1].endd;
    ans+=k/u;
    for(i=1;i<n;i++)
    {
        k=a[i].start-a[i-1].endd;
        ans+=k/u;
    }
    cout<<ans<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Septembre_/article/details/82982368
今日推荐