#K82792. Maximum Simultaneous Emergency Calls

    ID: 36054 Type: Default 1000ms 256MiB

Maximum Simultaneous Emergency Calls

Maximum Simultaneous Emergency Calls

In emergency response systems, it is crucial to understand the maximum load at any given time. Given several test cases, each consisting of multiple emergency call intervals, your task is to determine the maximum number of calls that are active (i.e. overlapping) simultaneously.

For each interval, a call starts at time (s_i) and ends at time (e_i). The number of calls active at time (t) can be represented as (O(t)=\sum_{i=1}^{n} \mathbf{1}{[s_i, e_i)} (t)). Your goal is to compute (\max{t \in \mathbb{R}} O(t)) for each test case.

Note: At the exact end time of a call, that call is considered finished before any new call starting at the same time is counted.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains a single integer (T) representing the number of test cases.
  • For each test case:
    • The first line contains a single integer (N) denoting the number of emergency calls.
    • The following (N) lines each contain two integers (s) and (e) separated by a space, representing the start and end times of a call.

For example:

6
5
30 120
60 150
90 180
210 300
240 360
3
100 200
150 250
200 300
5
50 100
51 101
52 102
53 103
54 104
1
10 20
4
1 5
5 10
10 15
15 20
2
1 1000
500 1500

outputFormat

For each test case, output a single line containing the maximum number of emergency calls being handled simultaneously. The output should be printed to standard output (stdout).## sample

6
5
30 120
60 150
90 180
210 300
240 360
3
100 200
150 250
200 300
5
50 100
51 101
52 102
53 103
54 104
1
10 20
4
1 5
5 10
10 15
15 20
2
1 1000
500 1500
3

2 5 1 1 2

</p>