1 条题解
-
0
见注释:
#include<bits/stdc++.h> using namespace std; int n; struct Interval{ int low;//起始 int high;//终止 }a[50005]; bool cmp(Interval x,Interval y){//比较 if(x.low!=y.low){ return x.low<y.low;//起始从小到大排序 } return x.high<y.high; } int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].low>>a[i].high;//输入 } sort(a+1,a+n+1,cmp);//比较 for(int i=1;i<=n;i++){ if(a[i].high<a[i+1].low){ //如果a[i]终止<a[i+1]起始,无法对接 cout<<"no"<<endl;//输出"no" return 0; } } //输出起始与终止 cout<<a[1].low<<' '<<a[n].high; return 0; }
- 1
信息
- ID
- 300
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者