takumi's blog

By takumi, history, 11 years ago, In English

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;

}

Full text and comments »

  • Vote: I like it
  • -12
  • Vote: I do not like it