
 一开始轻视这道题了,想用各种各样奇怪的区间标记把这道题水掉,结果WA声一片。。(我大意了,没有AC!)
 后来大脑开始思考,贪心解决掉了,AC快乐~~(忽略这道题来自分治…qwq)
思路
先按左端点sort,从头往后看此时往右延伸到的max是否比下一个的左端点大或等,是则OK,继续,否则一定不行了
代码
#include
 #include
 #include
 #include
 #include
 using namespace std;
 const int M=INT_MAX;
 struct line{
 int st,ed;
 }p[50005];
 bool cmp(line x,line y){
 return x.st<y.st;
 }
 int main(){
 int n;
 scanf("%d",&n);
 for(int i=1;i<=n;i++){
 scanf("%d%d",&p[i].st,&p[i].ed);
 }
 sort(p+1,p+1+n,cmp);
 int mx=p[1].ed;
 for(int i=1;i<=n;i++){
 if(mx<p[i].st){
 printf(“no”);
 return 0;
 }
 mx=max(mx,p[i].ed);
 }
 printf("%d %d",p[1].st,mx);
 return 0;
 }