CF1027F.Session in BSU

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line of the input contains one integer nn ( 1n1061 \le n \le 10^6 ) — the number of exams.

The next nn lines contain two integers each: aia_i and bib_i ( 1ai<bi1091 \le a_i < b_i \le 10^9 ), where aia_i is the number of day of the first passing the ii -th exam and bib_i is the number of day of the second passing the ii -th exam.

输入格式

If Polycarp cannot pass all the nn exams, print -1. Otherwise print the minimum index of day by which Polycarp can do that.

输出格式

输入输出样例

  • 输入#1

    2
    1 5
    1 7
    

    输出#1

    5
    
  • 输入#2

    3
    5 13
    1 5
    1 7
    

    输出#2

    7
    
  • 输入#3

    3
    10 40
    40 80
    10 80
    

    输出#3

    80
    
  • 输入#4

    3
    99 100
    99 100
    99 100
    

    输出#4

    -1
    
首页