2014 Mock CCC by Alex and Timothy
Alice figured out where Bob works, and has obtained a job there so she
can secretly admire him at work. Because she is new, the position is
only part-time, and she is always called in to shifts by her boss.
Whenever this happens, she is offered various shifts to pick from,
starting and ending at different times of the day. Alice knows that Bob
works from
Alice's employer has given her a list of the shifts that she can choose from in order of decreasing pay. Given this list, Alice would like to know which one would result in the longest period of time that both of them are simultaneously on the job. If multiple shifts yield the same time spent with Bob, she would like to know the highest paying out of those (i.e. the one that appears earliest in the list).
Input Specification
Line
Line
The next
Times in the input will be in the
Output Specification
The start and end time of the shift that Alice should pick to maximize
the time she gets to spend on the job with Bob. If there are multiple
answers, pick the one that is higher up on the list. If none of the
shifts overlap with Bob's shift, output Call in a sick day.
, since Alice has no interest in wasting her time at work when
Bob is not there.
Sample Input
10:30AM 07:00PM
4
05:30AM 10:00AM
11:00AM 08:15PM
01:45PM 05:00PM
08:00PM 11:00PM
Sample Output
11:00AM 08:15PM
Explanation
Bob works from 10:30AM to 7:00PM. If Alice picks the shift from 1:45PM
to 5:00PM, she will spend
Comments
hint for testcase 3?
Make sure to account for the fact that 12:00AM is midnight (0:00) and 12:00PM is noon.
Remember that 12:00PM is earlier than times like 1:00PM and same thing for AM.
Hope this helps!