Workout for a Dumbbell
Jump to navigation
Jump to search
This is a pretty straightforward simulation problem. Cache the last known time a machine user started on their machine. Each time jim arrives at a machine, mod the current time by the "total cycle time" of the fixed user of that machine. Also mod the cache'd last known start time of that machine user (assuming he is past his own start time). If modded start time plus the workout time (again mod total cycle time of that machine) is greater than the current modded time, then Jim has to wait. Calculate his wait time (difference between the two previously calculated values) to find out when he is able to start using the machine and when that machines user is next able to start using the machine. Update cached values accordingly and proceed.