PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000083. Lịch hẹn trùng nhau nhiều nhất (My Calendar III)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Lịch hẹn trùng nhau nhiều nhất (My Calendar III)
My Calendar III
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
An initially empty calendar receives bookings. Booking occupies the half-open interval . After each booking, report the largest number of simultaneous overlapping bookings seen so far.
Input
The first line contains , followed by lines in booking order. This is the stdin/stdout adaptation.
Output
Print lines; line gives the maximum number of overlapping bookings after the -th insertion.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
6
10 20
50 60
10 40
5 15
5 10
25 55
Output
1
1
2
3
3
3
Explanation
The first two bookings do not overlap. Adding yields a maximum overlap of . Adding raises it to on . Later bookings keep the maximum at .