Security Guard Staffing
Time limit1sMemory limit128 MB
Given per-shift minimum guard requirements for workday daylight, weekend daylight, and nighttime shifts, find the minimum total number of guards across four fixed cyclic shift schedules to meet all coverage constraints simultaneously.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics, Simulation
- Solved
- No attempts yet
Problem
The Agency of Criminal Matters (ACM) protects corporate offices with security guards who work 12-hour shifts. Every 24-hour day is split into a 12-hour daylight shift followed by a 12-hour nighttime shift, and each day begins with the daylight shift. Monday through Friday are workdays; Saturday and Sunday are weekends.
Each guard is assigned to exactly one of the following four schedules.
-
Schedule 1 — one full day of work (both the daylight and the nighttime shift) followed by two full days of rest; the guard works one day out of every three. It cycles regardless of the day of the week.
-
Schedule 2 — daylight shifts only, on all five workdays of the week; never at night and never on weekends. This schedule is tied to the days of the week.
-
Schedule 3 — a 4-day cycle: day 1 work (daylight and nighttime), day 2 rest, day 3 daylight only (rest at night), day 4 rest; three worked shifts every four days. It cycles regardless of the day of the week.
-
Schedule 4 — a 5-day cycle: day 1 work (daylight and nighttime), day 2 rest, day 3 daylight only, day 4 work (daylight and nighttime), day 5 rest. However, any daylight shift that would fall on a weekend is cancelled, so only nighttime shifts occur on weekends. It cycles regardless of the day of the week.
The protection requirements are:
- at least guards are on duty during every daylight shift on a workday,
- at least guards are on duty during every daylight shift on a weekend,
- at least guards are on duty during every nighttime shift (workday or weekend).
To simplify planning, the protection schedule must be regular: for each of the four schedules the number of guards on duty is the same integer constant across every daylight-workday shift, every nighttime-workday shift, every daylight-weekend shift, and every nighttime-weekend shift. (For example, if 4 guards on schedule 1 are on duty during one daylight workday shift, then 4 guards on schedule 1 are on duty during every daylight workday shift, though they may be different people.) A head count is a number of people, so it is always a non-negative integer.
Determine the minimum total number of guards that must be hired so that all requirements are met.
Input
One line with three integers , , (), separated by spaces. Here is the minimum number of guards required during daylight shifts on workdays, during daylight shifts on weekends, and during nighttime shifts.
Output
Print a single integer: the minimum total number of guards that must be hired to meet all requirements.