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 ...
随机推荐
- 2015南阳CCPC L - Huatuo's Medicine 签到
L - Huatuo's Medicine Description Huatuo was a famous doctor. He use identical bottles to carry the ...
- 2015南阳CCPC D - Pick The Sticks 背包DP.
D - Pick The Sticks Description The story happened long long ago. One day, Cao Cao made a special or ...
- HDFS01
==============NameNode============== 管理文件系统的命名空间 记录每个文件数据在各个DataNode上的位置和副本信息 协调客户端对文件的访问 NameNode文件 ...
- git命令颜色设置
+ $ git config --global color.status auto + $ git config --global color.diff auto + $ git config --g ...
- [SDOI 2009] 晨跑
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=1877 [算法] 不难看出,第一问要求的是最大流,第二问求的是最小费用最大流 注意建图 ...
- 蛤玮学计网 -- 简单的判断ip
心累 , 狗日的想了好多数据 , ......啥也不说了 我去哭一会 . #include<stdio.h> #include<string.h> #include<m ...
- 【Leetcode 86】 Partition List
问题描述: 给定一个list, 将所有小于x的node放到左边,剩下的保持原样. 问题解决: 闲的无聊,用c++和python都做了一遍. 代码如下: # Definition for singly- ...
- mysql索引的操作
一.创建和查看普通索引 这是最基本的索引类型,而且它没有唯一性之类的限制 1.创建表时创建普通索引 CREATE TABLE table_name( 属性名 数据类型, ... 属性名 数据类型, I ...
- HDU3949 XOR(线性基第k小)
Problem Description XOR is a kind of bit operator, we define that as follow: for two binary base num ...
- (转)Vue 爬坑之路(三)—— 使用 vue-router 跳转页面
使用 Vue.js 做项目的时候,一个页面是由多个组件构成的,所以在跳转页面的时候,并不适合用传统的 href,于是 vue-router 应运而生. 官方文档: https://router.vue ...