You are given a list of workers for a single day and many cutoff time queries. For each cutoff time, compute the total payroll paid up to that time using the same rules as the partial-shift problem:
- pay the full shift if it ends at or before the cutoff,
- pay 0 if it starts at or after the cutoff,
- otherwise pay only the portion from start_time up to the cutoff.
A naive solution that scans every worker for every query may be too slow. Implement an efficient solution that preprocesses the day's data and returns the payroll for all cutoff times in the original query order.
All times are in 24-hour "HH:MM" format, shifts stay within the same day, and time precision is one minute.
Examples
Input: ([{'id': 'A', 'hourly_rate': 10, 'start_time': '09:00', 'end_time': '12:00'}, {'id': 'B', 'hourly_rate': 20, 'start_time': '10:00', 'end_time': '11:00'}], ['08:00', '10:00', '10:30', '12:00'])
Expected Output: [0.0, 10.0, 25.0, 50.0]
Explanation: At 08:00 nobody has worked. At 10:00 only A has worked 1 hour. At 10:30 A has worked 1.5 hours and B has worked 0.5 hours. At 12:00 both full amounts are included.
Input: ([{'id': 'A', 'hourly_rate': 24, 'start_time': '09:15', 'end_time': '10:45'}, {'id': 'B', 'hourly_rate': 60, 'start_time': '10:00', 'end_time': '10:30'}], ['09:15', '10:00', '10:15', '11:00'])
Expected Output: [0.0, 18.0, 39.0, 66.0]
Explanation: The answers reflect cumulative pay at each cutoff, including partial overlap for both workers.
Input: ([], ['00:00', '23:59'])
Expected Output: [0.0, 0.0]
Explanation: With no workers, every query returns 0.
Input: ([{'id': 'A', 'hourly_rate': 60, 'start_time': '00:00', 'end_time': '00:01'}, {'id': 'B', 'hourly_rate': 120, 'start_time': '23:58', 'end_time': '23:59'}], ['00:00', '00:01', '23:58', '23:59'])
Expected Output: [0.0, 1.0, 1.0, 3.0]
Explanation: The first worker contributes 1 dollar by 00:01. The second contributes 2 more dollars by 23:59, for a total of 3.