#C7879. Minimum Conference Rooms

    ID: 51798 Type: Default 1000ms 256MiB

Minimum Conference Rooms

Minimum Conference Rooms

You are given \(n\) meeting intervals represented as pairs \( [s,e] \) (with \(s < e\)). Your task is to determine the minimum number of conference rooms required so that no meetings overlap. Two meetings \([s_1, e_1]\) and \([s_2, e_2]\) do not overlap if \(e_1 \leq s_2\) or \(e_2 \leq s_1\).

For example, if the intervals are \( [1,4], [2,5], [7,9] \), then at most two meetings occur concurrently, so the answer is 2. Use a greedy strategy with a min-heap (priority queue) to keep track of ongoing meetings.

inputFormat

The input is read from 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 \(s\) and \(e\) representing the start and end times of a meeting.

outputFormat

Output a single integer to stdout representing the minimum number of conference rooms required.

## sample
3
1 4
2 5
7 9
2