#C1305. Maximize Non-Overlapping Events Scheduling
Maximize Non-Overlapping Events Scheduling
Maximize Non-Overlapping Events Scheduling
Given a list of events, each event is represented by its start time and end time, determine the maximum number of non-overlapping events that can be scheduled in a single conference room.
You are required to implement a greedy algorithm that sorts the events by their finishing times. The input is provided via standard input and the output via standard output.
The input format is as follows:
- The first line contains an integer n, denoting the number of events.
- The following n lines each contain two integers representing the start time and end time of an event.
Output a single integer representing the maximum number of non-overlapping events.
inputFormat
The first line contains an integer n (0 ≤ n ≤ 105), the number of events. Each of the next n lines contains two space-separated integers, the start time and the end time of an event. It is guaranteed that the start time is less than the end time for each event.
outputFormat
Output a single integer representing the maximum number of non-overlapping events that can be scheduled in a single room.
## sample3
1 3
2 4
3 5
2