In Uber's internal accounting system, each trip generates a receipt that must be printed and archived.
Uber offers n types of receipt paper packs, where each pack type i contains 2^i receipt sheets and costs paperCost[i] units.
The finance team needs to print at least requiredReceipts number of trip receipts.
They can purchase:
Any number of packs
Multiple packs of the same type
The objective is to minimize total cost while ensuring at least requiredReceipts sheets are available.
long getMinimumPaperCost(int[] paperCost, int requiredReceipts)
Example 1
Input:
n = 5 paperCost = [2, 5, 7, 11, 25] requiredReceipts = 26
Output: 37
Explanation: Buy:
2 packs of type 0 → 2 × 2⁰ = 2 sheets
3 packs of type 3 → 3 × 2³ = 24 sheets
Total sheets = 26 Total cost = 2×2 + 3×11 = 37
1 ≤ n ≤ 30
1 ≤ paperCost[i] ≤ 10^9
1 ≤ requiredReceipts ≤ 10^