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

 

Vasya has recently got a job as a cashier at a local store. His day at work is LLminutes 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 liliminutes. 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 nL and a (0n10^51L10^91aL).

The i-th of the next n lines contains two integers titi and lili (0tiL11liL). It is guaranteed that ti+liti+1 and tn+lnL.

Output

Output one integer  — the maximum number of breaks.

Examples

Input
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 25 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<iostream>
using namespace std;
typedef long long ll;
ll n,l,a,ans;
int main()
{
   cin>>n>>l>>a;
    int worktime=0; 
    for(int i=1;i<=n;++i)
  {
        int ti,li;
    cin>>ti>>li;
        ans+=(ti-worktime)/a; 
    worktime=ti+li;
    }
  ans+=(l-worktime)/a;
   cout<<ans<<endl;
}

 

 

 

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注

4 × 5 =