ExpertSimulation & Finance50 points

Hospital shift payroll with night and Sunday premiums

A hospital in Nairobi pays nurses by the minute from a weekly roster. A shift may cross midnight. Premiums are added to the base rate for each minute worked:

  • minutes that fall on a Sunday (calendar day, so a Saturday night shift earns it after midnight): +100% (the rate doubles)
  • night minutes from 22:00 up to but not including 06:00: +25% of the base rate
  • every minute beyond the employee's first 2400 paid minutes (40 hours) of the week, in the order the shifts are listed: +50% of the base rate

Premiums add up (a Sunday night minute beyond 40 hours pays base times (1 + 1 + 0.25 + 0.5)). Pay for an employee is the sum over minutes of base rate times the multiplier divided by 60, rounded once at the end to whole cents, halves up.

Task: line 1: m, the number of employees. Next m lines: name rate_cents_per_hour. Then s, the number of shifts, and s lines name Day HH:MM HH:MM with Day one of Mon, Tue, Wed, Thu, Fri, Sat, Sun and the start and end time of the shift. If the end time is not later than the start time, the shift ends the next day. Shifts of one employee are listed in chronological order and never overlap. Print one line per employee, sorted by name: name: HhMMm pay X.XX showing total paid time (hours, then minutes with 2 digits) and the pay in currency units with 2 decimals.

Sample tests

Input

2
Wanjiru 1200
Otieno 1500
5
Wanjiru Mon 08:00 16:30
Wanjiru Tue 08:00 16:00
Otieno Sat 20:00 06:00
Otieno Sun 22:00 02:00
Wanjiru Wed 09:15 12:45

Expected output

Otieno: 14h00m pay 375.00
Wanjiru: 20h00m pay 240.00

Input

1
Amina 1000
6
Amina Mon 06:00 14:00
Amina Tue 06:00 14:00
Amina Wed 06:00 14:00
Amina Thu 06:00 14:00
Amina Fri 06:00 14:00
Amina Sat 06:00 14:00

Expected output

Amina: 48h00m pay 520.00

Your answer is also checked against 3 hidden tests.