#C11651. Gym Equipment Usage Analysis

    ID: 40991 Type: Default 1000ms 256MiB

Gym Equipment Usage Analysis

Gym Equipment Usage Analysis

You are given the schedule of gym equipment usage. Each test case provides a list of time intervals during which a piece of equipment is occupied. Your task is to determine the maximum number of equipment that are occupied simultaneously at any moment during the day.

For each test case, if we define \(count(t)\) as the number of intervals that satisfy \(start \le t < end\), you need to compute:

$$\max_{t \in \mathbb{R}}\; count(t)$$

This problem can be efficiently solved using a sweep-line algorithm.

inputFormat

The input is read from standard input (stdin). The first line contains an integer T, the number of test cases. For each test case:

  • The first line contains an integer N, the number of intervals.
  • Each of the next N lines contains two space-separated integers, representing the start and end times of an interval.

outputFormat

For each test case, output a single line containing one integer: the maximum number of overlapping intervals (i.e. the maximum number of equipment used simultaneously).

## sample
5
3
30 150
120 300
250 400
4
100 200
200 300
300 400
400 500
5
10 20
20 30
30 40
40 50
50 60
3
30 60
45 90
60 120
4
10 50
20 60
30 70
40 80
2

1 1 2 4

</p>