#K77742. Maximum Number of Non-Overlapping Events
Maximum Number of Non-Overlapping Events
Maximum Number of Non-Overlapping Events
You are given a set of events. Each event is represented by its start time and end time. Two events are considered overlapping if the start time of an event is not strictly greater than the end time of the last chosen event. Your task is to determine the maximum number of non-overlapping events that can be selected.
Note: An event is defined by a pair of integers. Events are considered non-overlapping if for an event i with start time s_i and end time e_i, and the previously selected event with end time e, the condition s_i > e
holds.
Input will be provided via standard input and output via standard output.
inputFormat
The first line contains a single integer N representing the number of events. The following N lines each contain two space-separated integers representing the start and end times of an event.
Example:
3 1 2 3 4 5 6
outputFormat
Output a single integer representing the maximum number of non-overlapping events that can be selected.
Example:
3## sample
1
1 2
1
</p>