Cashier (codeforces 1059A)
题目倒是不难注意第一个时间段可能不是从零开始的,所以注意第一个时间的开始节点与零之间可能存在休息的时间
还有这个题我打的时候一直谜之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)的更多相关文章
- Codeforces Beta Round #10 B. Cinema Cashier 暴力
B. Cinema Cashier 题目连接: http://www.codeforces.com/contest/10/problem/B Description All cinema halls ...
- Codeforces Beta Round #10 B. Cinema Cashier (树状数组)
题目大意: n波人去k*k的电影院看电影. 要尽量往中间坐,往前坐. 直接枚举,贪心,能坐就坐,坐在离中心近期的地方. #include <cstdio> #include <ios ...
- Codeforces Round #514 (Div. 2)
目录 Codeforces 1059 A.Cashier B.Forgery C.Sequence Transformation D.Nature Reserve(二分) E.Split the Tr ...
- CodeForces 867B Save the problem
B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...
- Educational Codeforces Round 12 B. Shopping 暴力
B. Shopping 题目连接: http://www.codeforces.com/contest/665/problem/B Description Ayush is a cashier at ...
- 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 ...
- 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 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
随机推荐
- OpenCV2马拉松第25圈——直线拟合与RANSAC算法
计算机视觉讨论群162501053 转载请注明:http://blog.csdn.net/abcd1992719g/article/details/28118095 收入囊中 最小二乘法(least ...
- 配置远程连接mysql数据库 Connect to remote mysql database
设有本地机器(local machine), ip地址为localip 远程机器(remote machine), ip地址remoteip 要通过在local machine的终端连接remote ...
- 软件project—思考项目开发那些事(一)
阅读文件夹: 1.背景 2.项目管理,质量.度量.进度 3.软件开发是一种设计活动而不是建筑活动 4.高速开发(简单的系统结构与复杂的业务模型) 5.技术人员的业务理解与产品经理的业务理解的终于业务模 ...
- excel 字符串拼接 添加 超链接
=HYPERLINK("http://"&C2,"http://"&C2)
- kafka02
- 【OI】向量&矩阵乘法
何为向量? 在初中课本中,我们知道: 向量是有大小和方向的量. 这样解释太笼统了,现在我们只讨论平面上的向量. 那么,我们约定:在平面上的向量,由一个二元组组成:如α(c1,c2). 在此平面上建立一 ...
- RatingBar android:isIndicator="true"
有时候我们用RatingBar只须要显示不让它选择或改变,解决办法是设置属性 android:isIndicator="true" isIndicator的意思是:是否是指示器,如 ...
- C# 获得资源文件下图片的路径
最终实现正确的代码是: button8.Image = System.Drawing.Image.FromFile(@"..\\..\\Resources\\GAOJIBAN.png&quo ...
- PCB 模拟Windows管理员域帐号安装软件
在我们PCB行业中,局域网的电脑一般都会加入域控的,这样可以方便集中管理用户权限,并可以对访问网络资源可以进行权限限制等. 由于加入了域控对帐号权限的管理,这样一来很多人都无权限安装软件,比如:PCB ...
- P3187 [HNOI2007]最小矩形覆盖
传送门 首先这个矩形的一条边肯定在凸包上.那么可以求出凸包然后枚举边,用类似旋转卡壳的方法求出另外三条边的位置,也就是求出以它为底最上面最右边最左边的点的位置.离它最远的点可以用叉积求,最左最右的可以 ...