PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000066. Phân lớp học (Classrooms)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Phân lớp học (Classrooms)
Classrooms
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are activities, each occupying time from to , and classrooms. Each room hosts at most one activity at a time. Even activities that meet at an endpoint cannot share a room. Each activity may be scheduled once. Maximize the number of activities assigned to rooms.
Input
The first line contains . The next lines have .
Output
Print the maximum number of schedulable activities.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every .
- Subtask 3 (50 points): ; ; for every .
Examples
Input
3 1
1 3
3 5
4 6
Output
2
Explanation
There is one classroom. Intervals and conflict at time . Choosing and schedules two activities; three cannot fit.