首页 > 其他 > 详细

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

时间:2019-12-01 09:57:47      阅读:65      评论:0      收藏:0      [点我收藏+]
//只要从所有区间右端点的最小值覆盖到所有区间左端点的最大值即可
#include<iostream>
using namespace std ;
int x,y;
int n;
int t;
int main() {
    cin>>t;
    while(t--) {
        cin>>n;
        if(n==1) {
            cin>>x>>y;
            cout<<0<<endl;
        } else {
            int l=0,r=1e9+10;
            for(int i=1; i<=n; i++) {
                cin>>x>>y;
                l=max(l,x);
                r=min(r,y);
            }
            int ans=max(0,l-r);
            cout<<ans<<endl;
        }
    }
    return 0;
}

 

 

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

原文:https://www.cnblogs.com/QingyuYYYYY/p/11964894.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!