PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000267. Chồng nhiều lịch học (Overlapping Class Schedules)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chồng nhiều lịch học (Overlapping Class Schedules)
Overlapping Class Schedules
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
There are classes. Class runs during the half-open interval . For each , compute the total duration with exactly active classes. Intervals may coincide; the length of is .
Input
First line: . Next lines: .
Output
Print integers on one line, where is the total duration with exactly active classes.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Example 1
Input
3
1 4
2 5
4 6
Output
2 3 0
Explanation
[1,2) and [5,6) have one class; [2,5) has two; none have three.
Example 2
Input
2
0 3
0 3
Output
0 3
Explanation
Both classes coincide for 3 time units.