UberOA #60
Find Point Illuminated by Most Lamps
估计中等可在线判题
考点(AI 标注)前缀和区间
A lamp (x,r) lights the closed interval [x−r,x+r], with r>0. Return the position lit by the most lamps at once; if several positions tie, take the smallest coordinate.
This site has made the standard input and output explicit.
输入格式
The first line contains n, followed by n lines of x r. On this site 1≤n≤200000, −10⁹≤x≤10⁹, 1≤r≤10⁹.
输出格式
Output one integer, the answer.
样例 1
输入:
3
-2 3
2 3
2 1
输出:
1
样例 2
输入:
2
-2 1
2 1
输出:
-3
样例 3
输入:
2
0 1
2 1
输出:
1
样例说明
Example 1: the only position shared by all three lamps is 1. Example 2: at most one lamp lights any position, and the leftmost such position is −3. Example 3: the two segments meet at the closed endpoint 1, which is lit by both lamps, so the answer is 1.