← 返回 amazon 的题目列表Meeting Rooms III
类型:online_judge
There are n rooms numbered from 0 to n - 1 and an array meetings, where meetings[i] = [start_i, end_i] denotes a meeting during the half-closed interval [start_i, end_i). All meeting start times are unique.
Process meetings in increasing start time:
If rooms are available, assign the meeting to the available room with the smallest index.
If no room is available, delay the meeting until the room that becomes free earliest is available. The delayed meeting keeps its original duration. If multiple rooms become free simultaneously, choose the smallest room index.
Return the room index that held the most meetings; break ties by choosing the smallest index.
Input format
Line 1: Integer n.
Line 2: Integer m.
Next m lines: Two integers, start end.
Output format
Print the index of the most booked room.
Constraints
1 <= n <= 100
1 <= m <= 10^5
0 <= start_i < end_i <= 5 * 10^5
All start_i are unique.
Example
Input
2
4
0 10
1 5
2 7
3 4
Output
0