//只要从所有区间右端点的最小值覆盖到所有区间左端点的最大值即可
#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. 小白的linux笔记8:linux自动运行爬虫并发送提醒邮件

    有了成功运行的爬虫后,希望能每天定时运行,且遇到错误时能及时发出提醒. 发出提醒 可以用mailx发出邮件做提醒.没有的话先安装Yum install mailx. 以qq邮箱为例,需要设置/etc/ ...

  2. EasyUI笔记(六)数据表格

    前言用asp.net结合easyui做个一个数据网格的页面,包括对数据的增删改查,界面如下:  一.UI界面 先写UI界面,代码如下,记得引入相关js和css文件 <body> <t ...

  3. centos7 lnmp环境搭建

    1- 安装gcc c++编译器 yum install gcc gcc-c++ cmake 2- 安装nginx-1.8.1及依赖包 2.1- 安装nginx依赖包 yum -y install pc ...

  4. 如何规范git commit提交

    相信很多人使用SVN.Git等版本控制工具时候都会觉得每次提交都要写一个注释有什么用啊?好麻烦,所以我每次都是随便写个数字就提交了,但是慢慢的我就发现了,如果项目长期维护或者修改很久之前的项目,没有一 ...

  5. 深入理解 C/C++ sizeof() 运算符

    过去有一段时间一直以为带个括号的 \(sizeof()\) 是 \(C/C++\) 的原生函数QAQ. 其实不然,\(sizeof\) 同位运算符(^|&~!)一样是一种单目运算符,作用于变量 ...

  6. vc6 保存文件卡住

    解决办法:删除工程文件中的三个文件,分别是:*.ncb  * .opt   * .plg引用链接:https://blog.csdn.net/lvxianlong123/article/details ...

  7. Wannafly Winter Camp 2020 Day 6A Convolution - NTT

    求 \(\sum_{i=1}^n \sum_{j=1}^n 2^{a_ia_j}\) Solution 化简一下 \[ 2^{a_ia_j} = p^{(a_i+a_j)^2-a_i^2-a_j^2} ...

  8. Window Api 通过账号密码访问共享文件夹

    using System; using System.Runtime.InteropServices; namespace PushGCodeService { public class Shared ...

  9. 谷歌浏览器chrome应用商店无法打开的解决方法

    解决办法:谷歌访问助手 谷歌访问助手是一款免费的谷歌服务代理插件,不用配置就可以正常访问谷歌的大部分服务,而且速度也很快.下载地址:http://www.cnplugins.com/advsearch ...

  10. jquery form表单赋值封装

    ;!(function ($) { $.fn.setFormValue = function (options) { var $this = $(this); $.each(options, func ...