#C9523. Maximum Overlapping Events
Maximum Overlapping Events
Maximum Overlapping Events
You are given several events, each specified by a start time and an end time in the format HH:MM
. An event represents a time interval \([start, end)\), meaning that if one event ends exactly when another begins, they do not overlap. Your task is to calculate the maximum number of events that overlap at any point in time.
Input Format: The input is read from stdin
. The first line contains an integer T representing the number of test cases. Each test case starts with an integer N indicating the number of events, followed by N lines. Each of these lines contains two strings representing the start time and end time of an event in HH:MM
format.
Output Format: For each test case, output the maximum number of overlapping events on a new line to stdout
.
The relation for converting a time string to minutes since midnight is given by:
[ \text{minutes} = \text{HH} \times 60 + \text{MM} ]
inputFormat
The input begins with an integer T (1 ≤ T
) on the first line. For each test case, the first line contains an integer N (1 ≤ N
), the number of events. This is followed by N lines each containing two strings: the start and end times in HH:MM
format.
Example:
3 1 09:00 10:00 2 09:00 10:00 10:00 11:00 4 09:00 10:30 09:15 10:00 10:00 11:00 09:45 10:45
outputFormat
For each test case, output a single integer representing the maximum number of overlapping events. Each output should be printed on a new line.
Example:
1 1 3## sample
3
1
09:00 10:00
2
09:00 10:00
10:00 11:00
4
09:00 10:30
09:15 10:00
10:00 11:00
09:45 10:45
1
1
3
</p>