#K41002. Maximum Shoppers in the Mall
Maximum Shoppers in the Mall
Maximum Shoppers in the Mall
You are given one or more test cases. Each test case corresponds to a series of time intervals during which shoppers are present in a mall. Each interval is represented by two integers: the entry time and the exit time of a shopper. Your task is to determine the maximum number of shoppers present in the mall concurrently for each test case.
Formally, for each test case, consider a set of intervals \([a_i, b_i]\) for \(i=1,2,\dots,N\). You need to compute the maximum value of \(\sum_{i=1}^{N} I(a_i \le t \le b_i)\) where \(I(\cdot)\) is the indicator function. In other words, find the time \(t\) at which the number of overlapping intervals is maximized.
inputFormat
The input is read from standard input (stdin) and has the following format:
T N1 a11 b11 a12 b12 ... a1N1 b1N1 N2 a21 b21 a22 b22 ... a2N2 b2N2 ... NT aT1 bT1 ... aTN_T bTN_T
Here, T is the number of test cases. For each test case, the first line contains an integer N representing the number of shoppers (intervals). The following N lines each contain two integers denoting the entry time and exit time respectively.
outputFormat
For each test case, output a single integer on a new line which is the maximum number of shoppers concurrently present in the mall.
## sample2
3
1 5
2 6
4 8
4
1 3
2 5
4 8
6 10
3
2
</p>