#K57837. Maximum Overlapping Tasks for Employees

    ID: 30509 Type: Default 1000ms 256MiB

Maximum Overlapping Tasks for Employees

Maximum Overlapping Tasks for Employees

You are given the schedules of multiple employees. Each employee has a list of tasks and each task is represented by its start time and end time. Tasks are considered overlapping if they have any intersecting durations, except when one task ends exactly when the next task begins (in which case they do not overlap). Your job is to determine, for each employee, the maximum number of tasks that are active (overlapping) at any point in time.

More formally, for an employee with tasks intervals \((s_i, e_i)\) for \(i=1,2,\dots,T\), find the maximum value of \(f(t)\) over time, where

[ f(t)=\text{number of tasks such that } s_i \le t < e_i ]

and report that number for each employee.

The input is given in stdin and the output must be written to stdout.

inputFormat

The input is read from stdin and is formatted as follows:

E
emp_id1 T1
s11 e11
s12 e12
... (T1 lines)
emp_id2 T2
s21 e21
s22 e22
... (T2 lines)
... 

Where:

  • E is the number of employees.
  • For each employee, the first line contains the employee id (emp_id) and the number of tasks (T).
  • Each of the following T lines contains two integers representing the start and end times of a task.
  • Note that if one task ends at the same time another begins, they are not considered overlapping.

outputFormat

For each employee, output a line containing two integers separated by a space: the employee id and the maximum number of overlapping tasks for that employee, preserving the order of input.

## sample
3
1 4
1 4
2 6
5 8
7 10
2 4
2 4
3 5
7 9
10 12
3 3
5 7
6 8
8 10
1 2

2 2 3 2

</p>