Maximize Pipeline Throughput
Examples
Example 1:
Input: throughput = [2,5], cost = [1,2], budget = 4
Output: 6
Explanation:
Example 2:
Input: throughput = [4,6,3], cost = [2,3,1], budget = 10
Output: 12
Explanation:
Example 1:
Input: throughput = [2,5], cost = [1,2], budget = 4
Output: 6
Explanation:
Example 2:
Input: throughput = [4,6,3], cost = [2,3,1], budget = 10
Output: 12
Explanation:
A request pipeline is made of n services connected in series, so the output of service i feeds into service i + 1. The overall throughput of the pipeline is the minimum throughput across all services.
You are given:
throughput, where throughput[i] is the base throughput of service icost, where cost[i] is the cost of scaling service i up oncebudget, the total amount you may spendYou may scale any service i up x times (x >= 0). After scaling, that service's throughput becomes throughput[i] * (1 + x) and it consumes x * cost[i] of the budget. The combined cost of all scale-ups must not exceed budget.
Return the maximum overall pipeline throughput you can achieve.
Scale service 0 twice (throughput 6, cost 2) and service 1 once (throughput 10, cost 2). Total cost 4 fits the budget and the overall throughput is min(6, 10) = 6.
Raise every service to 12: service 0 x2 (cost 4), service 1 x1 (cost 3), service 2 x3 (cost 3). Total cost 10 and the overall throughput is 12.
throughput.length == cost.length == n1 <= n1 <= throughput[i]1 <= cost[i]0 <= budget