PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000074. Tham dự nhiều sự kiện nhất (Maximum Number of Events That Can Be Attended)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tham dự nhiều sự kiện nhất (Maximum Number of Events That Can Be Attended)
Maximum Number of Events That Can Be Attended
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are events. Event may be attended on one chosen day in the inclusive range . You may attend at most one event per day and count each event at most once. Find the maximum number of events that can be attended.
Input
The first line contains integer . Each of the next lines contains two integers .
Output
Print the maximum number of events.
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
3
1 2
2 3
3 4
Output
3
Explanation
Attend event on day , on day , and on day . Each event is attended on one allowed day, so all three can be attended.