Minimum Time to Complete All Deliveries
You are given two integer arrays of size 2: d = [d1, d2] and r = [r1, r2].
Two delivery drones are tasked with completing a specific number of deliveries. Drone i must complete di deliveries.
Each delivery takes exactly one hour and only one drone can make a delivery at any given hour.
Additionally, both drones require recharging at specific intervals during which they cannot make deliveries. Drone i must recharge every ri hours, meaning at hours that are multiples of ri.
Return an integer denoting the minimum total time, in hours, required to complete all deliveries.
Example 1
Input
d = [3,1], r = [2,3]Output
5The first drone can deliver at hours 1, 3, and 5 while the second drone delivers at hour 2, so all deliveries finish by hour 5.
Example 2
Input
d = [1,3], r = [2,2]Output
7Both drones recharge at hours 2, 4, and 6, so one valid schedule finishes the first drone at hour 3 and the second drone at hours 1, 5, and 7.
Constraints
- d = [d1, d2]
- 1 <= di <= 10^9
- r = [r1, r2]
- 2 <= ri <= 3 * 10^4