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 ...
随机推荐
- ffplay.c函数结构简单分析(绘图)
近期重温了一下FFplay的源码. FFplay是FFmpeg项目提供的播放器演示样例.虽然FFplay不过一个简单的播放器演示样例,它的源码的量也是不少的. 之前看代码,主要是集中于某一个" ...
- SuperSocket中的Server是如何初Start的
第一个函数 d:\sourcecode\github\supersocket\quickstart\basic\telnetserver_startbyconfig\program.cs static ...
- 【POJ 2965】 The Pilots Brothers' refrigerator
[题目链接] http://poj.org/problem?id=2965 [算法] 位运算 [代码] #include <algorithm> #include <bitset&g ...
- web跨域问题回顾
晚上看spring web源码时看到了cors包,查了一下原来是在4.2之后新加的用来更方便让web应用服务支持cors协议的.于是有了下面几个问题. web跨域问题的起源是因为浏览器为了安全而遵循的 ...
- shell脚本-循环选择语句
shell脚本-循环选择语句 过程式编程语言: 顺序执行 选择执行 循环执行 注:条件中的变量,可以在执行语句中使用,不用在加上"$". if语句 根据命令的退出状态来执行命令 单 ...
- P4046 [JSOI2010]快递服务
传送门 很容易想出\(O(n^3m)\)的方程,三维分别表示某个快递员现在在哪里,然后直接递推即可 然而这样会T,考虑怎么优化.我们发现每一天的时候都有一个快递员的位置是确定的,即在前一天要到的位置. ...
- Java根据年度将数据分组
现在有这么一组数据 code name year 45615654 x1 ...
- 个人微信二次开发API接口
通过这个API接口可以做什么? 通过我们提供的API接口您可以开发: 工作手机(如:X创,X码,XX管家等) 微信群讲课软件(如:讲课X师,一起X堂等) 微信社群管理软件(如:小X管家,微X助手等) ...
- 【洛谷4396/BZOJ3236】[AHOI2013]作业(莫队+分块/树状数组/线段树)
题目: 洛谷4396 BZOJ3236(权限) 这题似乎BZOJ上数据强一些? 分析: 这题真的是--一言难尽 发现题面里没说权值的范围,怕出锅就写了离散化.后来经过面向数据编程(以及膜神犇代码)知道 ...
- ACM_Mystery
Mystery Time Limit: 2000/1000ms (Java/Others) Problem Description: No Description Input: The first l ...