提交时间:2025-07-15 10:14:36
运行 ID: 332686
#include<bits/stdc++.h> using namespace std; struct hsg{ int si,ei; } sgh[110]; bool cmp(hsg si,hsg ei){ return si.ei<ei.ei; } int main(){ while(1){ int n; cin>>n; if(n==0) break; for(int i=1;i<=n;i++){ cin>>sgh[i].si>>sgh[i].ei; } sort(sgh+1,sgh+n+1,cmp); int x=sgh[1].ei,g=1; for(int i=2;i<=n;i++){ if(sgh[i].si>=x){ g++; x=sgh[i].si; } } cout<<x<<endl; } return 0; }