include
include
include
include
include
include
include
using namespace std;
typedef struct node { long long int a,b ;
}node ;
int arrange(node a,node b) { if(a.a<b.a) { return 1 ;
}
else if(a.a==b.a)
{
if(a.b<=b.b)
{
return 1;
}
else
{
return 0 ;
}
}
return 0 ;
}
int main() { int n ; cin>>n ;
vector<node> list(n);
for(int i=0;i<n;i++)
{
cin>>list[i].a ;
cin>>list[i].b ;
}
sort(list.begin(),list.end(),arrange) ;
long long int ans = list[0].b;
for(int i=1;i<n;i++)
{
if(list[i].b<ans)
{
ans= list[i].a ;
}
else if(list[i].b>=ans)
{
ans = list[i].b;
}
}
cout<<ans<<endl;
return 0;
}








What are the constraints? If n = 0 is possible then "long long int ans = list[0].b;" will result in a RTE.
http://codeforces.me/problemset/problem/479/C
No ,(1 ≤ n ≤ 5000). Is there anything else that can cause the RTE .
Thank You
Comparator is wrong. It shouldn't return true for two equal objects. This has been discussed on Codeforces countless times.
Typical implementation would be:
Thank you so much, sorry for posting a repeated query .