Equal Schedules
Time limit1sMemory limit1024 MB
Given two on-call schedules, print how much each teammate's on-call time changed from the first schedule to the second, sorted by name.
- Level
Easy2 of 10
- Topics
- Hash map, Implementation, String, Sorting
- Solved
- No attempts yet
Problem
You are one of the people on-call for a high-availability service that lets users solve programming tasks. Your team has an on-call schedule that says who is responsible for the service at each time.
A colleague sent you a new schedule. You want to check that everyone has the same on-call time as before, and print any differences.
The on-call schedule is written as lines of the form . Here and are the start and end offsets of a shift, counted from some start hour, and is the teammate on call for that shift.
For example, take this schedule.
0 7 jan
7 14 tomaz
14 20 jure
20 24 jan
24 25 tomaz
25 26 jure
jan is on call for the first 7 hours (hours 0 through 6), and tomaz is on call for the next 7. In total, jan is on call for 11 hours, tomaz for 8, and jure for 7.
Input
The input contains two schedules separated by a line ------. Each schedule has one or more lines of the form , where the integers and mean that teammate is on call for hours from up to but not including . A final line ====== comes after the second schedule.
Output
Print the differences between the two schedules as , where is the second schedule's on-call time minus the first schedule's on-call time for teammate . Sort the output by teammate name in alphabetical order. Omit teammates with no difference. Every printed difference has a + or - sign. If no differences exist, print No differences found.
Constraints
For each schedule, the following holds:
- The name consists of lowercase English letters.