#K12296. Maximum Non-Overlapping Bookings
Maximum Non-Overlapping Bookings
Maximum Non-Overlapping Bookings
You are given a list of bookings represented by time intervals. Each booking is represented by a start time and an end time, forming an interval \( [s, e) \). Two bookings are non-overlapping if the start time of one is not less than the end time of another, i.e. for two bookings \( (s_i, e_i) \) and \( (s_j, e_j) \), they do not overlap if \( s_j \ge e_i \). Your task is to choose the maximum number of bookings such that no two bookings overlap.
Note: The input starts with an integer \( N \) representing the number of bookings, followed by \( N \) lines each containing two space-separated integers corresponding to the start and the end times, respectively.
inputFormat
The input is read from stdin and has the following format:
N s1 e1 s2 e2 ...</p>sN eN
Where \( N \) (an integer) is the number of bookings, and each subsequent line contains two space-separated integers \( s_i \) and \( e_i \) representing the start and end times of each booking.
outputFormat
Output a single integer to stdout representing the maximum number of non-overlapping bookings that can be accepted.
## sample1
1 2
1