#C491. Maximum Number of Non-Overlapping Meetings
Maximum Number of Non-Overlapping Meetings
Maximum Number of Non-Overlapping Meetings
You are given a list of meetings, where each meeting is represented by its start time and end time. Your task is to determine the maximum number of meetings you can schedule such that no two meetings overlap. Two meetings are considered non-overlapping if the start time of a meeting is greater than or equal to the end time of the previous meeting. This condition can be written in LaTeX as:
\( s_j \geq e_i \)
where \( s_j \) is the start time of the current meeting and \( e_i \) is the end time of the last meeting that was scheduled.
The meetings are assumed to start and end at integer times. Think of this as a typical greedy scheduling problem where sorting by the meeting end times often yields the optimal solution.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \( n \) representing the number of meetings.
- The next \( n \) lines each contain two space-separated integers indicating the start time and end time of a meeting.
outputFormat
The output, printed to standard output (stdout), is a single integer representing the maximum number of non-overlapping meetings that can be scheduled.
## sample5
1 3
2 4
3 5
6 8
5 7
3
</p>