cswork / OA打开练习工作台

IBMOA #30

Get Max Traffic Time

估计中等可在线判题

考点(AI 标注)前缀和区间

Each visitor is online during the closed interval [start,end]. Find the earliest integer time at which the number of visitors online at the same time is the largest.

输入格式

The first line contains n, followed by n lines of start end. 1≤n≤100000, 1≤start≤end; the source's upper bound on time is truncated, so this site adds end≤10^9.

输出格式

Output one integer, the answer.

样例 1

输入:

4
1 7
6 8
2 6
9 10

输出:

6

样例 2

输入:

2
1 1
2 2

输出:

1

样例 3

输入:

2
4 4
4 8

输出:

4

样例说明

The examples give 6, 1 and 4 respectively; a visitor is still online at the end point, and ties go to the earliest time.