A. Cashier
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output
【Problem】
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?
http://codeforces.com/contest/1059/problem/A
【题解】
简单的模拟
要注意到从一开始(时间点0时刻)到第一个人来的那段时间
【AC代码】
#include<cstdio>
int n,l,a,ans,b[100020],f[100020];
int main()
{
scanf("%d%d%d",&n,&l,&a);
b[0]=0;f[0]=0;
for(register int i=1;i<=n;++i)
{
scanf("%d%d",&b[i],&f[i]);
f[i]+=b[i];
}
b[n+1]=l;f[n+1]=l;
for(register int i=0;i<=n;++i)
ans+=(b[i+1]-f[i])/a;
printf("%d",ans);
return 0;
}