训练赛-签到题1

题目链接:https://vjudge.net/contest/260134#problem/A
题目: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
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 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.
题目大意:Vasya一共工作L分钟,抽一根烟要a分钟,有顾客时不能抽烟,求V他最多能抽几根烟。
因为ti+li≤ti+1ti+li≤ti+1 所以只需要根据输入顺序计算Vasya有多少空闲时间进行抽烟。
AC代码:

#include<cstdio>
using namespace std;
int main(){
    int n,l,a;
    while(scanf("%d%d%d",&n,&l,&a)!=EOF){
        int temp=0,sum=0;
        int t,tt;
        for(int i=0;i<n;i++){
            scanf("%d%d",&t,&tt);
            sum+=(t-temp)/a;
            temp=t+tt;
        }
    sum+=(l-temp)/a;
    printf("%d\n",sum);
    return 0;
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值