n walls to paint and two painters on site.
- The **pro** charges price[i] coins for wall i and spends hours[i] hours on it.
- The **helper** works for free and paints any wall in 1 hour, but only while the pro is busy. When the pro is idle, so is the helper.
Every wall is painted by exactly one of them. Return the minimum total amount you have to pay to get all the walls painted.price=[7, 3, 9, 4], hours=[1, 2, 2, 1] → 7
The pro paints walls 1 and 3 for 3 + 4 = 7 coins and 3 hours of work. During those 3 hours the helper paints walls 0 and 2 for free.
price=[5, 6, 2, 8, 1], hours=[1, 1, 1, 1, 1] → 8
Every paid wall buys the helper one hour, which is one more wall. So the pro needs three of the five walls, and the cheapest three cost 1 + 2 + 5 = 8.
price=[10], hours=[3] → 10
There is only one wall, and the helper cannot start while the pro is idle, so we pay 10.
price=[7, 3, 9, 4], hours=[1, 2, 2, 1]
7
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.