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 ...
随机推荐
- 【ubuntu firefox】 Firefox is already running, but is not responding
在ubuntu下启动firefox报错 Firefox is already running, but is not responding. To open a new window, you mus ...
- Android自定义用户控件简单范例(一)
一款优秀的移动应用需要具有自己独特统一的风格,通常情况下UI设计师会根据产品需求和使用人群的特点,设计整体的风格,界面的元素和控件的互效果.而原生态的Android控件为开发人员提供的是最基本的积木元 ...
- Expressions-->Member lookup
7.4 Member lookup 在word文档的第140页 A member lookup is the process whereby凭借:通过…:借以:与…一致 the meaning of ...
- [POI 2018] Prawnicy
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=5102 [算法] 首先,n条线段的交集一定是[Lmax,Rmin] , 其中,Lmax ...
- MSP430:管脚的第二功能选择
之前在使用PWM,AD时候用到过第二功能,不过都是copy没有注意过PXSEL究竟怎么设置,今天在设置晶振管脚时候遇到了麻烦,细致看了一下其实很简单,在SPEC的最后详细讲了每个管脚如何设置为其他功能 ...
- Weblogic 启动慢解决方法
添加 启动参数 : -Xms256m -Xmx512m -XX:MaxPermSize=256m 原因 : 实际是JVM在Linux下的bug:他想调用一个随机函数,但是取不到. 暂时 ...
- CSS伪类对象before和after的实例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 局部覆盖element-ui的默认样式
最近项目中遇到的问题,只想在某个页面里面单独更改element-ui的样式,而不影响全局 有两种方法: 1.在需要更改的组件里新增一个style标签[重点:不要加scoped],然后直接获取class ...
- Python基础数据类型(三)list 列表
3.4列表list [] 列表的格式 lst_l = [1,'123',[1,'www',2],'包青天'] 列表也有索引 print(lst_l[0]) print([-1][0:2]) #包青 切 ...
- javascript 获取时间
Js获取当前日期时间及其它操作 var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); ...