题目倒是不难注意第一个时间段可能不是从零开始的,所以注意第一个时间的开始节点与零之间可能存在休息的时间

还有这个题我打的时候一直谜之RE。。。。。。发现原来bool函数忘记写return了。。。。。以后一定主函数也写上,return 0;也写上

#include <bits/stdc++.h>
using namespace std;
struct node
{
int l,coss;
}p[1000100];
bool cmp(node aa,node bb)
{
return aa.l<bb.l;
}
main()
{
memset(p,0,sizeof(p));
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n,L,a;
cin>>n>>L>>a;
for(int i=0;i<n;i++)
cin>>p[i].l>>p[i].coss;
//sort(p,p+n,cmp);
int ans=0;
ans+=p[0].l/a;
for(int i=0;i<n-1;i++)
{
if(p[i].l+p[i].coss<p[i+1].l)
ans+=(p[i+1].l-p[i].coss-p[i].l)/a;
}
if(n!=0)
ans+=(L-p[n-1].l-p[n-1].coss)/a;
else
ans+=L/a;
cout<<ans;
}

Cashier (codeforces 1059A)的更多相关文章

  1. Codeforces Beta Round #10 B. Cinema Cashier 暴力

    B. Cinema Cashier 题目连接: http://www.codeforces.com/contest/10/problem/B Description All cinema halls ...

  2. Codeforces Beta Round #10 B. Cinema Cashier (树状数组)

    题目大意: n波人去k*k的电影院看电影. 要尽量往中间坐,往前坐. 直接枚举,贪心,能坐就坐,坐在离中心近期的地方. #include <cstdio> #include <ios ...

  3. Codeforces Round #514 (Div. 2)

    目录 Codeforces 1059 A.Cashier B.Forgery C.Sequence Transformation D.Nature Reserve(二分) E.Split the Tr ...

  4. CodeForces 867B Save the problem

    B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...

  5. Educational Codeforces Round 12 B. Shopping 暴力

    B. Shopping 题目连接: http://www.codeforces.com/contest/665/problem/B Description Ayush is a cashier at ...

  6. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature【枚举二分答案】

    https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the rea ...

  7. Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature

    链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but ...

  8. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  9. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

随机推荐

  1. LeetCode 387. First Unique Character in a String (字符串中的第一个唯一字符)

    题目标签:String, HashMap 题目给了我们一个 string,让我们找出 第一个 唯一的 char. 设立一个 hashmap,把 char 当作 key,char 的index 当作va ...

  2. POJ 1741 Tree 树形DP(分治)

    链接:id=1741">http://poj.org/problem?id=1741 题意:给出一棵树,节点数为N(N<=10000),给出N-1条边的两点和权值,给出数值k,问 ...

  3. Error:全局变量不明白(using namespace std 与全局变量的冲突)

    在用递归写八皇后时,定义了一个全局变量count,结果出现故障例如以下:提示全局变量不明白. 最后发如今实现文件.cpp中.我使用了using  namespace std; 解决方法: 1.使用co ...

  4. code+3月赛 loj6299 白金元首与克劳德斯

    千里白金雪满天 烽火江山起狼烟 分手竟兵刃相见 1941.7. 苏联军队出乎意料的反抗力量.前线德军的补给困难 —— 元首 Adolf 望着天空的云层陷入沉思…… 在 xyxyxy-直角坐标平面的天空 ...

  5. 洛谷 P3398 仓鼠找sugar —— 树链剖分

    题目:https://www.luogu.org/problemnew/show/P3398 树链剖分一下,路径就变成线段树上的几个区间: 两条路径相交就是线段树上有区间相交,所以在相应位置打个标记, ...

  6. Word中公式和文字混排对齐的问题

    全选-字体-字符间距-位置-标准-确定 段落-中文版式-文本对齐方式-居中-确定

  7. PCB CE工具取Genesis JOB与STEP内存地址 方法分享

    今天无意中在硬盘上找到了<CE工具取Genesis JOB与STEP内存地址 >视频, 这是2013年初由郭兄(永明)远程时录制的一段视频,特别感谢郭兄指引与帮助, 想当初要不是你推出全行 ...

  8. thinkphp结合云之讯做短信验证码

    thinkphp结合云之讯做短信验证码先去云之讯注册账号 网址http://www.ucpaas.com/ 注册云之讯平台账号,即可免费获得10元测试费用测试够用啦 解压附件到 ThinkPHP\Li ...

  9. IDEA新项目代码上传到gitlab远程仓库

    IDEA新项目代码上传到gitlab远程仓库 具体步骤 创建本地仓库 IDEA:VCS-->Import into Version Control-->Create Git Reposit ...

  10. js 调用微信浏览器内置方法,启动支付

    $.post("{php echo app_url('pay/cash')}",{orderno:orderno,paytype:paytype},function(m){ //t ...