You are given an integer period, an integer array lights, and an integer array arrivalTime.
There are several traffic lights, each operating on a synchronized repeating cycle of length period. For a traffic light with a green duration of lights[i], the light is green from time lights[i] (exclusive) within each cycle, and red for the rest of the cycle.
When a vehicle arrives at time arrivalTime[j], its position within the cycle is
If lights[i], the traffic light is green, resulting in a waiting time of
If lights[i], the traffic light is red, and the vehicle must wait until the beginning of the next cycle, resulting in a waiting time of period
Each vehicle can be assigned to any traffic light in lights independently. The penalty of an assignment is defined as the maximum waiting time among all vehicles.
Return the minimum possible penalty achievable after assigning every vehicle to an optimal traffic light.
Constraints:
period
lights.length
lights[i] period
arrivalTime.length
arrivalTime[i]
You are given an integer period, an integer array lights, and an integer array arrivalTime.
There are several traffic lights, each operating on a synchronized repeating cycle of length period. For a traffic light with a green duration of lights[i], the light is green from time lights[i] (exclusive) within each cycle, and red for the rest of the cycle.
When a vehicle arrives at time arrivalTime[j], its position within the cycle is
If lights[i], the traffic light is green, resulting in a waiting time of
If lights[i], the traffic light is red, and the vehicle must wait until the beginning of the next cycle, resulting in a waiting time of period
Each vehicle can be assigned to any traffic light in lights independently. The penalty of an assignment is defined as the maximum waiting time among all vehicles.
Return the minimum possible penalty achievable after assigning every vehicle to an optimal traffic light.
Constraints:
period
lights.length
lights[i] period
arrivalTime.length
arrivalTime[i]