#C8938. Maximum Overlapping Shifts
Maximum Overlapping Shifts
Maximum Overlapping Shifts
In this problem, you are given a list of work shifts. Each shift is specified by a start time and an end time in the (\text{HH:MM}) format. Two shifts are considered overlapping if they share at least a moment in time. Note that if one shift ends at the exact time another begins, they are not considered overlapping.
Your task is to determine the maximum number of overlapping shifts at any given time. To achieve this, you will need to convert the time from the given string format into minutes elapsed since midnight (00:00) and then use a sweep line algorithm to track the number of overlapping shifts.
The algorithm works by creating "events" for each shift's start and end times, sorting these events by time (with end events processed before start events if they occur at the same time), and then iterating through the events to count overlaps.
The formula used for converting a time string (HH:MM) to minutes is given by: [ \text{minutes} = \text{hours} \times 60 + \text{minutes} ]
Good luck!
inputFormat
The input is read from standard input (stdin). The first line contains an integer (N), the number of shifts. This is followed by (N) lines, each containing two strings representing the start and end time of a shift in the (HH:MM) format, separated by space.
outputFormat
Output a single integer to standard output (stdout) representing the maximum number of overlapping shifts.## sample
3
09:00 17:00
12:00 20:00
11:00 15:00
3