当前位置: 首页 > 工具软件 > Cashier-BTC > 使用案例 >

A. Cashier

赵明亮
2023-12-01

滴答滴答---题目链接

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;

}

 

 类似资料:

相关阅读

相关文章

相关问答