#K16081. Maximum Non-Overlapping Events
Maximum Non-Overlapping Events
Maximum Non-Overlapping Events
You are given a list of events, where each event is represented by its start time and end time. Your task is to determine the maximum number of non-overlapping events that can be scheduled.
An event is defined as an interval where is the start time and is the end time. Two events and are non-overlapping if and only if .
You may consider using a greedy algorithm that sorts the events by their end times to achieve an optimal solution.
inputFormat
The first line contains an integer representing the number of events. Each of the following lines contains two integers separated by a space, representing the start time and end time of an event.
outputFormat
Output a single integer representing the maximum number of non-overlapping events that can be scheduled.## sample
5
1 5
2 6
1 3
3 4
5 7
3