【题目链接】: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的更多相关文章

  1. 【27.91%】【codeforces 734E】Anton and Tree

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【29.89%】【codeforces 734D】Anton and Chess

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【13.77%】【codeforces 734C】Anton and Making Potions

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【81.37%】【codeforces 734B】Anton and Digits

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【77.39%】【codeforces 734A】Anton and Danik

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【25.00%】【codeforces 584E】Anton and Ira

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 508B】Anton and currency you all know

    [题目链接]:http://codeforces.com/contest/508/problem/B [题意] 给你一个奇数; 让你交换一次数字; 使得这个数字变成偶数; 要求偶数要最大; [题解] ...

  8. 【codeforces 785E】Anton and Permutation

    [题目链接]:http://codeforces.com/problemset/problem/785/E [题意] 给你一个初始序列1..n顺序 然后每次让你交换任意两个位置上面的数字; 让你实时输 ...

  9. 【codeforces 785D】Anton and School - 2

    [题目链接]:http://codeforces.com/contest/785/problem/D [题意] 给你一个长度为n的括号序列; 让你删掉若干个括号之后,整个序列变成前x个括号为左括号,后 ...

随机推荐

  1. The Swift Programming Language 中文翻译版

    原文(http://www.cnblogs.com/lkvt/p/3765349.html) 一.Welcome to Swift 1.关于Swift Swift是一种用于iOS和OS X应用的全新编 ...

  2. C语言创建删不掉的目录

    上一篇博客写了一个杀不死的进程,如今再写一个删不掉的目录(文件同理),所谓删不掉不是真的删不掉而是删掉后立即又一次创建. 代码例如以下: #include <stdio.h> #inclu ...

  3. orabbix 报错No suitable driver found for

     orabbix报错如下:   2018-07-11 14:35:20,119 [main] ERROR Orabbix - Error on Configurator for database qa ...

  4. C语言深度剖析-----数组与指针分析

    数组的本质: 指针的运算: 小标VS指针: a和&a的区别: 例: 数组参数: 所以下例返回4 指针和数组的对比小结:

  5. 前端js常用正则表达式实例讲解

    本文内容整理自他人优秀的博客,非纯原创.仅借此学习和整理. 1.匹配用户名 规则描述: 长度4-6位: {4,16} 字母: [a-z] [A-Z] 数字: [0-9] 下划线: [_] 减号: [- ...

  6. PHP的工作原理和生命周期

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u013778883/article/details/79831035   php是一门适用于web开 ...

  7. UIActionSheet用法

    //上拉菜单 1 UIActionSheet* sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonT ...

  8. win32程序如何改变字体大小颜色

    //设定文字大小和颜色 LOGFONT logfont; //改变输出字体 ZeroMemory(&logfont, sizeof(LOGFONT)); logfont.lfCharSet = ...

  9. Java中compareTo()方法比较字符串详解

    中心:String 是字符串,它的比较用compareTo方法,它从第一位开始比较, 如果遇到不同的字符,则马上返回这两个字符的ascii值差值.返回值是int类型 1.当两个比较的字符串是英文且长度 ...

  10. ArcEngine由点生成TIN

    这两天替别人写一个三维校园的展示程序.用的是SceneControl二次开发. 须要利用DOM和TIN构建三维地形.如今说下依据高程点生成TIN的过程: (1)依据高程点文件(Excel)生成点sha ...