#C7456. Maximum Simultaneous Participants

    ID: 51329 Type: Default 1000ms 256MiB

Maximum Simultaneous Participants

Maximum Simultaneous Participants

You are given one or more test cases. For each test case, you are given an integer \( n \) and \( n \) time intervals. Each time interval is represented by two integers \( s \) and \( e \) where \( s \) is the start time and \( e \) is the end time. A participant is considered to be active in the time interval \([s, e)\). Your task is to determine the maximum number of participants that are active at the same time for each test case.

Note: If two events occur at the same time, the event that ends is considered to occur before the event that starts.

Input constraints: \(1 \leq n \leq 10^5\) (per test case), and the time values can be assumed to be integers within a reasonable range.

inputFormat

The first line of input contains an integer \( T \), the number of test cases. For each test case, the first line contains an integer \( n \), the number of participants (intervals). The next \( n \) lines each contain two space-separated integers \( s \) and \( e \), representing the start and end time, respectively.

Example:

2
3
1 4
2 5
3 6
4
2 8
3 5
5 7
6 9

outputFormat

For each test case, output the maximum number of participants that are active simultaneously. Each answer should be printed on a new line.

Example:

3
3
## sample
1
3
1 4
2 5
3 6
3

</p>