【codeforces 785B】Anton and Classes
【题目链接】:http://codeforces.com/contest/785/problem/B
【题意】
给你两个时间各自能够在哪些时间段去完成;
让你选择两个时间段来完成这两件事情;
要求两段时间的间隔最长(休息的时间最长)
【题解】
考虑最后的答案;
只会是
(l,r).....(left,right)
(left,right)...(l,r)
else
这3种情况
对于第一种记录第一件事右端点的最小值,第二件事左端点的最大值;
对于第二种记录第二件事右端点的最小值,第一件事左端点的最大值;
用这两种情况尝试更新答案;
如果答案不为0,则输出它,否则剩下的情况都是相交的;直接输出0就好;
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
#define ref(x) scanf("%lf",&x)
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110;
int l, r, left, right,zdl=0,zxr=1e9,zdleft=0,zxright=1e9;
int n, m,x,y,ans = 0;
void input_data()
{
rei(n);
rep1(i, 1, n)
{
rei(x), rei(y);
zxr = min(zxr, y);
zdl = max(zdl, x);
}
rei(m);
rep1(i, 1, m)
{
rei(x), rei(y);
zxright = min(zxright, y);
zdleft = max(zdleft, x);
}
}
void get_ans()
{
if (zxr <= zdleft)
ans = max(ans, zdleft - zxr);
if (zxright <= zdl)
ans = max(ans, zdl - zxright);
}
void o()
{
cout << ans << endl;
}
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
input_data();
get_ans();
o();
//printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
return 0;
}
【codeforces 785B】Anton and Classes的更多相关文章
- 【27.91%】【codeforces 734E】Anton and Tree
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【29.89%】【codeforces 734D】Anton and Chess
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【13.77%】【codeforces 734C】Anton and Making Potions
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【81.37%】【codeforces 734B】Anton and Digits
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【77.39%】【codeforces 734A】Anton and Danik
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【25.00%】【codeforces 584E】Anton and Ira
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 508B】Anton and currency you all know
[题目链接]:http://codeforces.com/contest/508/problem/B [题意] 给你一个奇数; 让你交换一次数字; 使得这个数字变成偶数; 要求偶数要最大; [题解] ...
- 【codeforces 785E】Anton and Permutation
[题目链接]:http://codeforces.com/problemset/problem/785/E [题意] 给你一个初始序列1..n顺序 然后每次让你交换任意两个位置上面的数字; 让你实时输 ...
- 【codeforces 785D】Anton and School - 2
[题目链接]:http://codeforces.com/contest/785/problem/D [题意] 给你一个长度为n的括号序列; 让你删掉若干个括号之后,整个序列变成前x个括号为左括号,后 ...
随机推荐
- 【Codeforces Round #432 (Div. 2) B】Arpa and an exam about geometry
[链接]h在这里写链接 [题意] 给你3个点A,B,C 问你能不能将纸绕着坐标轴上的一点旋转.使得A与B重合,B与C重合 [题解] 这3个点必须共圆. 则A,B,C不能为一条直线.否则无解. 共圆之后 ...
- Notepad++使用心得和特色功能介绍 -> notepad/ultraedit的最好的替代品
[详细]Notepad++使用心得和特色功能介绍 -> notepad/ultraedit的最好的替代品 最近在用Notepad++,发现的确是很不错的工具,具体特色,看了下面介绍就知道了. [ ...
- JS学习笔记 - 面向对象 - 选项卡 (普通选项卡改写)
选项卡3 <script> window.onload=function () { new TabSwitch('div1'); }; function TabSwitch(id) // ...
- Linux高性能server编程——系统检測工具
系统检測工具 tcpdump tcpdump是一款经典的抓包工具,tcpdump给使用者提供了大量的选项,泳衣过滤数据报或者定制输出格式. lsof lsof是一个列出当前系统打开的文件描写叙述符的工 ...
- jqgrid 实现行编辑,表单编辑的列联动
这个问题的场景相信大家都遇到过,比方有A,B,C三列,B,C列均为下拉框.可是C列的值是由B列的值来决定的.即C列中的值是动态变化的,变化的根据就是B列中你选择的值. 本文给出的是一个有用,简易快捷的 ...
- QWaitCondition 的正确使用方法(通过 mutex 把有严格时序要求的代码保护起来,同时把 wakeAll() 也用同一个 mutex 保护起来)
简单用法 QWaitCondition 用于多线程的同步,一个线程调用QWaitCondition::wait() 阻塞等待,直到另一个线程调用QWaitCondition::wake() 唤醒才继续 ...
- HttpClient证书回调问题解决
/// <summary> /// httpclient请求 /// </summary> /// <param name=&q ...
- HZK16应用实例
在C51中,HZK16汉字库的使用(mydows's Blog转载) 定义如下: unsigned char str[]="我" 个字节长度,内容为"我"的GB ...
- CQRS之旅——旅程6(我们系统的版本管理)
旅程6:我们系统的版本管理 准备下一站:升级和迁移 "变化是生活的调味品."威廉·考珀 此阶段的最高目标是了解如何升级包含实现CQRS模式和事件源的限界上下文的系统.团队在这一阶段 ...
- AE 获取地图上当前选中的要素
樱木 原文 AE开发----获取地图上当前选中的要素 Code1 int selCount = axMapControl1.Map.SelectionCount; IEnumFeature pEnum ...