//只要从所有区间右端点的最小值覆盖到所有区间左端点的最大值即可
#include<iostream>
using namespace std ;
int x,y;
int n;
int t;
int main() {
cin>>t;
while(t--) {
cin>>n;
if(n==) {
cin>>x>>y;
cout<<<<endl;
} else {
int l=,r=1e9+;
for(int i=; i<=n; i++) {
cin>>x>>y;
l=max(l,x);
r=min(r,y);
}
int ans=max(,l-r);
cout<<ans<<endl;
}
}
return ;
}

Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) A Math Problem的更多相关文章

  1. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3

    A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...

  2. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) F2. Wrong Answer on test 233 (Hard Version) dp 数学

    F2. Wrong Answer on test 233 (Hard Version) Your program fails again. This time it gets "Wrong ...

  3. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) E. Arson In Berland Forest 二分 前缀和

    E. Arson In Berland Forest The Berland Forest can be represented as an infinite cell plane. Every ce ...

  4. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) D2. Optimal Subsequences (Hard Version) 数据结构 贪心

    D2. Optimal Subsequences (Hard Version) This is the harder version of the problem. In this version, ...

  5. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C. Messy 构造

    C. Messy You are fed up with your messy room, so you decided to clean it up. Your room is a bracket ...

  6. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B. Box 贪心

    B. Box Permutation p is a sequence of integers p=[p1,p2,-,pn], consisting of n distinct (unique) pos ...

  7. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) A. Math Problem 水题

    A. Math Problem Your math teacher gave you the following problem: There are n segments on the x-axis ...

  8. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C Messy

    //因为可以反转n次 所以可以得到任何可以构成的序列 #include<iostream> #include<string> #include<vector> us ...

  9. Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) B Box

    #include<bits/stdc++.h> using namespace std; ]; ]; int main() { int total; cin>>total; w ...

随机推荐

  1. cf959E

    题意简述:一个包含n个点的完全图,点的编号从0开始,两个点之间的权值等于两个点编号的异或值,求这个图的最小生成树 规律是 ∑ i from 0 to n-1 (i&-i) #include & ...

  2. PostgreSQL内核学习笔记十一(索引)

    Index Scan涉及到两部分的内容Heap Only Tuple和index-only-scan. 什么是Heap Only Tuple(HOT)? 例如:Update a Row Without ...

  3. P3902 递增

    链接:P3902 ----------------------------------------- 这道题就是最长上升子序列的模板题,因为我们修改的时候可没说不能改成小数(暴力) --------- ...

  4. c#FTP基本使用

    public class FtpHelper { //基本设置 private static string ftppath = @"ftp://" + "192.168. ...

  5. [SDOI2012] 任务安排 题解

    有感而发,遂书. 其实和sze聊了很久,但他还是退役了.恐怕他是本届里学oi时间最长的一个人吧,从小学五年级开始.我也是因为他,才开始学oi的.他因为学校的压力,不得不放弃.或许是没什么天赋.学了4年 ...

  6. 疑问:Iterator 遍历器和数据集合各种遍历方法的区别

    https://es6.ruanyifeng.com/#docs/iterator Iterator(遍历器)的概念 Iterator 接口主要供for...of消费 Iterator 的遍历过程是: ...

  7. JS实现粒子拖拽吸附特效-sunziren

    特效的效果就如同本页面的背景一样,有粒子随机移动.连结,甚至是吸附到你的鼠标周围. 代码如下,只要引入JQuery和一小段JS代码就可以了.本质上用到了Html5的canvas <script ...

  8. BZOJ 4239: 巴士走读 最短路

    显然,我们可以将询问按照规定时间从小到大排序,依次处理. 那么我们显然要求合法的点中从 $n$ 号点出发到达点 $i$ 的最迟时间,我们令这个为 $f[i]$ 而 $f[i]$ 显然可以用最短路来求. ...

  9. centos系统mongodb安装

    使用腾讯云搭服务器时,需要链接数据库,就从头开始重新安装了一遍mongodb,没想到这么麻烦,记得之前没这么麻烦. 1.下载mongodb(一篇博客的) 安装的是3.6版本 `` vim /etc/y ...

  10. eclipse配置文件出现小红叉,Referenced file contains errors (xml文件第一行小红叉错误)

    原文链接:https://blog.csdn.net/zlj1217/article/details/61432437                                          ...