Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Codeforces Round #514 (Div. 2) A. Cashier(水题)

Codeforces Round #514 (Div. 2) A. Cashier(水题)

作者头像
Ch_Zaqdt
发布于 2019-01-10 08:59:03
发布于 2019-01-10 08:59:03
37000
代码可运行
举报
文章被收录于专栏:Zaqdt_ACMZaqdt_ACM
运行总次数:0
代码可运行

题目链接:http://codeforces.com/contest/1059/problem/A

       题意是一个人需要工作n个时间段,一天需要工作l个小时,空闲时间大于x的时候可以休息一次,然后输入n个时间段,问在l的时间里可以最多休息几次。

       思路就是求区间的间隔时间,直接看代码吧。


AC代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
struct Node{
	int r,l;
}Edge[maxn];

int main()
{
	int n,l,x;
	scanf("%d%d%d",&n,&l,&x);
	if(n == 0){
		printf("%d\n",l / x);
		return 0;
	}
	for(int i=0;i<n;i++){
		scanf("%d%d",&Edge[i].r,&Edge[i].l);
	}
	int ans = 0;
	for(int i=1;i<n;i++){
		if(Edge[i].r - (Edge[i-1].r + Edge[i-1].l) >= x)
			ans += (Edge[i].r - (Edge[i-1].r + Edge[i-1].l)) / x;
	}
	ans += (Edge[0].r / x);
	ans += (l - (Edge[n-1].r + Edge[n-1].l)) / x;
	printf("%d\n",ans);
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018年10月07日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Codeforces Round #521 (Div. 3) C. Good Array(思维)
题目链接:http://codeforces.com/contest/1077/problem/C
Ch_Zaqdt
2019/01/10
5230
Codeforces Round #547 (Div. 3) C. Polycarp Restores Permutation(思维)
题目链接:https://codeforces.com/contest/1141/problem/C
Ch_Zaqdt
2019/03/22
4850
Educational Codeforces Round 63 (Rated for Div. 2) D. Beautiful Array(dp)
题目链接:https://codeforces.com/contest/1155/problem/D
Ch_Zaqdt
2019/05/10
3850
Codeforces Round #513 D. Social Circles(思维)
题目链接:http://codeforces.com/contest/1060/problem/D
Ch_Zaqdt
2019/01/11
3710
Codeforces Round #521 (Div. 3) D. Cutting Out(二分)
题目链接:http://codeforces.com/contest/1077/problem/D
Ch_Zaqdt
2019/01/10
5720
Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetra
Angel_Kitty
2018/04/08
9640
Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
Educational Codeforces Round 61 (Rated for Div. 2) C. Painting the Fence(思维+前缀和)
题目链接:http://codeforces.com/contest/1132/problem/C
Ch_Zaqdt
2019/03/15
4220
Codeforces Round #516 Div.2 D. Labyrinth(双端队列)
题目连接:http://codeforces.com/contest/1064/problem/D
Ch_Zaqdt
2019/01/11
4720
Codeforces Round #514 (Div. 2) B. Forgery(思维+暴力)
题目链接:http://codeforces.com/contest/1059/problem/B
Ch_Zaqdt
2019/01/10
4500
Codeforces Round #402 (Div. 2) D. String Game(二分)
题目链接:http://codeforces.com/contest/779/problem/D
Ch_Zaqdt
2019/01/10
4690
Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) B. Two Cakes(思维)
题目链接:http://codeforces.com/contest/1130/problem/B
Ch_Zaqdt
2019/03/08
4530
Codeforces Round #519 D. Mysterious Crime(思维)(1043D)
题目链接:http://codeforces.com/contest/1043/problem/D
Ch_Zaqdt
2019/01/10
5590
Educational Codeforces Round 60 (Rated for Div. 2) A. Best Subsegment(思维)
版权声明:欢迎转载,若转载,请标明出处,如有错误,请指点,也欢迎大佬们给出优化方法 https://blog.csdn.net/Charles_Zaqdt/article/details/87669332
Ch_Zaqdt
2019/03/13
3800
Codeforces Round #536 (Div. 2) B. Lunar New Year and Food Ordering(思维)
题目链接:http://codeforces.com/contest/1106/problem/B
Ch_Zaqdt
2019/03/05
4990
Codeforces Round #532 (Div. 2) E. Andrew and Taxi(二分+拓扑排序)
题目链接:https://codeforces.com/contest/1100/problem/E
Ch_Zaqdt
2019/03/04
4270
CodeCraft-19 and Codeforces Round #537 (Div. 2) C. Creative Snap(二分+分治)
题目链接:https://codeforces.com/contest/1111/problem/C
Ch_Zaqdt
2019/03/04
4700
Codeforces Round #558 (Div. 2) B. Cat Party(思维)
题目链接:https://codeforces.com/contest/1163/problem/B2
Ch_Zaqdt
2019/05/15
4250
ECJTUACM16 Winter vacation training #5 题解&源码
A------------------------------------------------------------------------------------------- 题目链接:http://codeforces.com/problemset/problem/714/A 解题思路: 【题意】 Sonya每天只有[l1,r1]时间段内空闲,且在k时刻,她要打扮而不能够见Filya Filya每天[l2,r2]时间段内空闲 问他们俩每天有多少时间能够在一起 【类型】 区间交 【分析】 显然
Angel_Kitty
2018/04/08
6310
ECJTUACM16 Winter vacation training #5 题解&源码
Codeforces Round #541 (Div. 2) F. Asya And Kittens(并查集+邻接表)
题目链接:https://codeforces.com/contest/1131/problem/F
Ch_Zaqdt
2019/03/06
5080
Codeforces Round #525 (Div. 2) B. Ehab and subtraction(思维)
题目链接:http://codeforces.com/contest/1088/problem/B
Ch_Zaqdt
2019/01/10
4600
推荐阅读
相关推荐
Codeforces Round #521 (Div. 3) C. Good Array(思维)
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验