PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000269. Đoạn có mức phủ lớn nhất (Maximum Coverage Duration)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đoạn có mức phủ lớn nhất (Maximum Coverage Duration)
Maximum Coverage Duration
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given half-open intervals , the coverage at a point is the number of intervals containing it, counting duplicates separately. Find the maximum coverage and the total length of all regions with coverage exactly . The length of is , not the number of endpoints.
Input
First line: . Next lines: .
Output
Print two integers on one line: maximum coverage and total length attaining it.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Example 1
Input
4
0 4
2 5
8 10
9 12
Output
2 3
Explanation
Coverage 2 occurs on [2,4) and [9,10), total length 3.
Example 2
Input
2
1 3
3 5
Output
1 4
Explanation
The intervals touch without overlapping; maximum coverage 1 lasts 4 units.