| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 28070 |
| 문제명 | 유니의 편지 쓰기 |
| 레벨 | 골드 5 |
| 분류 |
그리디 |
| 시간복잡도 | O(nlogn) |
| 인풋사이즈 | n<=100,000 |
| 사용한 언어 | Python 3.11 |
| 제출기록 | 61180KB / 324ms |
| 최고기록 | 240ms |
| 해결날짜 | 2023/05/30 |
"""Solution code for "BOJ 28070. 유니의 편지 쓰기".
- Problem link: https://www.acmicpc.net/problem/28070
- Solution link: http://www.teferi.net/ps/problems/boj/28070
"""
import sys
JOIN = 0
DISCHARGE = 1
def main():
N = int(sys.stdin.readline())
events = []
for _ in range(N):
join_month, discharge_month = sys.stdin.readline().split()
events.append((join_month, JOIN))
events.append((discharge_month, DISCHARGE))
max_count = count = 0
answer = None
for month, type_ in sorted(events):
count += 1 if type_ == JOIN else -1
if count > max_count:
max_count, answer = count, month
print(answer)
if __name__ == '__main__':
main()