CodeForces 785B Anton and Classes
简单判断。
找第一类区间中$R$最大的,以及第二类区间中$L$最小的,判断距离。
找第二类区间中$R$最大的,以及第一类区间中$L$最小的,判断距离。
两种情况取个最大值即可。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std; int n,m;
int a,b,c,d; int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x,y; scanf("%d%d",&x,&y);
if(i==1) a=y; else a = min(a,y);
if(i==1) c=x; else c = max(c,x);
} scanf("%d",&m);
for(int i=1;i<=m;i++)
{
int x,y; scanf("%d%d",&x,&y);
if(i==1) b=x; else b = max(b,x);
if(i==1) d=y; else d = min(d,y);
} printf("%d\n",max(max(b-a,0),max(c-d,0)));
return 0;
}
CodeForces 785B Anton and Classes的更多相关文章
- Codeforces Round #404 (Div. 2) B. Anton and Classes 水题
B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to pl ...
- CodeForce-785B Anton and Classes(简单贪心)
Anton and Classes Anton likes to play chess. Also he likes to do programming. No wonder that he deci ...
- 【codeforces 785B】Anton and Classes
[题目链接]:http://codeforces.com/contest/785/problem/B [题意] 给你两个时间各自能够在哪些时间段去完成; 让你选择两个时间段来完成这两件事情; 要求两段 ...
- Codeforces 734E. Anton and Tree 搜索
E. Anton and Tree time limit per test: 3 seconds memory limit per test :256 megabytes input:standard ...
- Codeforces 593B Anton and Lines
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output st ...
- Codeforces 734F Anton and School(位运算)
[题目链接] http://codeforces.com/problemset/problem/734/F [题目大意] 给出数列b和数列c,求数列a,如果不存在则输出-1 [题解] 我们发现: bi ...
- [刷题]Codeforces 785D - Anton and School - 2
Description As you probably know, Anton goes to school. One of the school subjects that Anton studie ...
- Codeforces 785D - Anton and School - 2 - [范德蒙德恒等式][快速幂+逆元]
题目链接:https://codeforces.com/problemset/problem/785/D 题解: 首先很好想的,如果我们预处理出每个 "(" 的左边还有 $x$ 个 ...
- Codeforces 584E - Anton and Ira - [贪心]
题目链接:https://codeforces.com/contest/584/problem/E 题意: 给两个 $1 \sim n$ 的排列 $p,s$,交换 $p_i,p_j$ 两个元素需要花费 ...
随机推荐
- NOIP模拟7
期望得分:100+100+20=220 实际得分:100+95+20=215 T1 洛谷 P1306 斐波那契公约数 #include<cstdio> #include<cstrin ...
- 在GitHub搭建个人博客 地址: https://douzujun.github.io/
搭建博客地址:https://douzujun.github.io/ 博客模板:https://github.com/douzujun/douzujun.github.io 显示效果:
- SpringCloud入门系列(一)
https://www.cnblogs.com/edisonchou/p/java_spring_cloud_foundation_sample_list.html
- Razor使用Parse()时最好指定“缓存名”
为什么? 本文的标题,明显有一种提醒的口吻. 从18年的生活经验看,如果想提醒人要怎么办,不要怎么办. 最好说明原因.那么小编开始说明原因喽. 哦对,说原因之前,先说交代一下背景,一句话 在非mvc下 ...
- 简易安装sqoop
版本 :hive-0.13.1-cdh5.3.6.tar.gz 1:解压 然后 进到 conf 目录 修改 sqoop-env.sh 2:如果使用mysql 数据库 要将 mysql驱动包拷贝到 ...
- NYOJ 231 Apple Tree (树状数组)
题目链接 描述 There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in t ...
- 仿360影视网站模板html
链接:http://pan.baidu.com/s/1mhIkV4s 密码:9wgq
- python进阶之关键字和运算符触发魔法方法
前言 python有众多的魔法方法,它们会在满足某种条件下触发执行,掌握好魔法方法的使用,可以加快程序的运行效率,同时减少逻辑调用. 关键字与魔法方法 python的一些魔法方法是关键字触发的,即py ...
- MySQL之——如何添加新数据库到MySQL主从复制列表 【转】
转自 转载请注明出处:http://blog.csdn.net/l1028386804/article/details/54653691 MySQL主从复制一般情况下我们会设置需要同步的数据库,使用参 ...
- mac下 mysql / nginx 问题总汇
"ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)&q ...