|
| 1 | +<h2><a href="https://leetcode.com/problems/minimum-time-to-complete-all-deliveries">4048. Minimum Time to Complete All Deliveries</a></h2><h3>Medium</h3><hr><p>You are given two integer arrays of size 2: <code>d = [d<sub>1</sub>, d<sub>2</sub>]</code> and <code>r = [r<sub>1</sub>, r<sub>2</sub>]</code>.</p> |
| 2 | + |
| 3 | +<p>Two delivery drones are tasked with completing a specific number of deliveries. Drone <code>i</code> must complete <code>d<sub>i</sub></code> deliveries.</p> |
| 4 | + |
| 5 | +<p>Each delivery takes <strong>exactly</strong> one hour and <strong>only one</strong> drone can make a delivery at any given hour.</p> |
| 6 | + |
| 7 | +<p>Additionally, both drones require recharging at specific intervals during which they cannot make deliveries. Drone <code>i</code> must recharge every <code>r<sub>i</sub></code> hours (i.e. at hours that are multiples of <code>r<sub>i</sub></code>).</p> |
| 8 | + |
| 9 | +<p>Return an integer denoting the <strong>minimum</strong> total time (in hours) required to complete all deliveries.</p> |
| 10 | + |
| 11 | +<p> </p> |
| 12 | +<p><strong class="example">Example 1:</strong></p> |
| 13 | + |
| 14 | +<div class="example-block"> |
| 15 | +<p><strong>Input:</strong> <span class="example-io">d = [3,1], r = [2,3]</span></p> |
| 16 | + |
| 17 | +<p><strong>Output:</strong> <span class="example-io">5</span></p> |
| 18 | + |
| 19 | +<p><strong>Explanation:</strong></p> |
| 20 | + |
| 21 | +<ul> |
| 22 | + <li>The first drone delivers at hours 1, 3, 5 (recharges at hours 2, 4).</li> |
| 23 | + <li>The second drone delivers at hour 2 (recharges at hour 3).</li> |
| 24 | +</ul> |
| 25 | +</div> |
| 26 | + |
| 27 | +<p><strong class="example">Example 2:</strong></p> |
| 28 | + |
| 29 | +<div class="example-block"> |
| 30 | +<p><strong>Input:</strong> <span class="example-io">d = [1,3], r = [2,2]</span></p> |
| 31 | + |
| 32 | +<p><strong>Output:</strong> <span class="example-io">7</span></p> |
| 33 | + |
| 34 | +<p><strong>Explanation:</strong></p> |
| 35 | + |
| 36 | +<ul> |
| 37 | + <li>The first drone delivers at hour 3 (recharges at hours 2, 4, 6).</li> |
| 38 | + <li>The second drone delivers at hours 1, 5, 7 (recharges at hours 2, 4, 6).</li> |
| 39 | +</ul> |
| 40 | +</div> |
| 41 | + |
| 42 | +<p><strong class="example">Example 3:</strong></p> |
| 43 | + |
| 44 | +<div class="example-block"> |
| 45 | +<p><strong>Input:</strong> <span class="example-io">d = [2,1], r = [3,4]</span></p> |
| 46 | + |
| 47 | +<p><strong>Output:</strong> <span class="example-io">3</span></p> |
| 48 | + |
| 49 | +<p><strong>Explanation:</strong></p> |
| 50 | + |
| 51 | +<ul> |
| 52 | + <li>The first drone delivers at hours 1, 2 (recharges at hour 3).</li> |
| 53 | + <li>The second drone delivers at hour 3.</li> |
| 54 | +</ul> |
| 55 | +</div> |
| 56 | + |
| 57 | +<p> </p> |
| 58 | +<p><strong>Constraints:</strong></p> |
| 59 | + |
| 60 | +<ul> |
| 61 | + <li><code>d = [d<sub>1</sub>, d<sub>2</sub>]</code></li> |
| 62 | + <li><code>1 <= d<sub>i</sub> <= 10<sup>9</sup></code></li> |
| 63 | + <li><code>r = [r<sub>1</sub>, r<sub>2</sub>]</code></li> |
| 64 | + <li><code>2 <= r<sub>i</sub> <= 3 * 10<sup>4</sup></code></li> |
| 65 | +</ul> |
0 commit comments