Codeforces1059A.Cashier题解

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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值