← 返回 bytedance 的题目列表Meeting Rooms III
类型:online_judge
There are n meeting rooms numbered from 0 to n - 1. You are given meetings, where meetings[i] = [start_i, end_i] is the originally scheduled start and end time of meeting i.
Apply these allocation rules:
Each meeting uses the available room with the smallest index.
If no room is available at a meeting's start time, delay the meeting until the earliest room becomes available, while preserving its duration.
If several rooms become available at the same time, choose the room with the smallest index.
Process meetings in ascending order of original start time; all start_i values are distinct.
Return the index of the room that hosts the most meetings. Break ties by returning the smallest index.
Input Format
First line: integer n, the number of rooms.
Second line: integer m, the number of meetings.
Next m lines: two integers start end.
Output Format
Print the index of the room that hosted the most meetings.
Example
Input:
2
4
0 10
1 5
2 7
3 4
Output:
0
Constraints
1 <= n <= 100
1 <= m <= 100,000
0 <= start_i < end_i <= 500,000
All start_i values are distinct.
Example
Input
2
4
0 10
1 5
2 7
3 4
Output
0