Codeforce 1059A. Cashier

有个店,来了N个客人,每个客人t时刻来,要服务l时间,然后就把他L时间的上班时间占用掉了一部分,然后求剩下时间里能摸多少次雨,摸一次鱼a时间。

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

 

#include
using namespace std;
int x[100005],y[100005];
int main()
{
	int n,l,a;
	cin>>n>>l>>a;
	int ans=0;
	int t1,l1; 
	if(n==0)
	{
		cout<>x[0]>>y[0];
	ans+=x[0]/a;
	for(int i=1;i>x[i]>>y[i];
			ans+=((x[i]-(x[i-1]+y[i-1]))/a);
		}
		
	ans+=((l-(x[n-1]+y[n-1]))/a);
	cout<

 

你可能感兴趣的:(ACM,Codeforce)