307843: CF1424G. Years
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Years
题意翻译
### 题目背景 (和能否做出题目无关,可以略过) 在一次宇宙探索中,人类找到了有关一个星球生命曾存在的证据.很幸运的是他们找到了有关这个星球每个生命的生卒年份,更有趣的是这些年份范围为$[1,10^9]$,因此这些人被称作"Longlifer". 为了解"Longlifer"星的人口数量,科学家希望知道"Longlifer"星的人口数量最大时的年份,及该年份的人口数,你的任务就是求出这两个数值! ### 题目描述 给定 $N(1 \leq N\leq 10^5)$个人的出生年份与死亡年份,求在世人数最多的年份 $y$ 与年份 $y$ 的在世人数 $k$. ### 输入输出格式 第一行输入一个整数 $N$ 表示人数. 接下来 $N$ 行,第 $i$ 行有两个整数 $b_{i},d_{i} (1 \leq b_{i} < d_{i} \leq 10^9)$ 表示第 $i$ 个人于 $b_{i}$ 年出生, $d_{i}$ 年逝世,即第 $i$ 个人于年份 $b_{i}$ 到年份$d_{i}-1$ 在世. 你应输出一行两个整数,由一个空格分开,分别是在在世人数最多的年份 $y$ 与年份 $y$ 的在世人数 $k$. 如果有多个年份在世人数均符合要求,输出 $y$ 最小的那个.题目描述
During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that these years are in the range $ (1, 10^9) $ ! Therefore, the planet was named Longlifer. In order to learn more about Longlifer's previous population, scientists need to determine the year with maximum number of individuals that were alive, as well as the number of alive individuals in that year. Your task is to help scientists solve this problem!输入输出格式
输入格式
The first line contains an integer $ n $ ( $ 1 \le n \le 10^5 $ ) — the number of people. Each of the following $ n $ lines contain two integers $ b $ and $ d $ ( $ 1 \le b \lt d \le 10^9 $ ) representing birth and death year (respectively) of each individual.
输出格式
Print two integer numbers separated by blank character, $ y $ — the year with a maximum number of people alive and $ k $ — the number of people alive in year $ y $ . In the case of multiple possible solutions, print the solution with minimum year.
输入输出样例
输入样例 #1
3
1 5
2 4
5 6
输出样例 #1
2 2
输入样例 #2
4
3 4
4 5
4 6
8 10
输出样例 #2
4 2