PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000261. Năm có dân số lớn nhất (Maximum Population Year)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Năm có dân số lớn nhất (Maximum Population Year)
Maximum Population Year
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Each of people contributes to the population in years through , excluding the death year . Find the earliest year attaining maximum population.
Input
First line: . Next lines: .
Output
Print the earliest year with maximum population.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Example 1
Input
2
1993 1999
2000 2010
Output
1993
Explanation
No overlapping lifespans; 1993 is the first year with population 1.
Example 2
Input
3
1950 1961
1960 1971
1970 1981
Output
1960
Explanation
Population is 2 in 1960 and 1970; choose 1960.