We’re preparing your current view and syncing the latest data.
Given two arrays capacity and cost, each of the same length n, and a budget value, determine the maximum capacity that can be achieved by selecting items such that their total cost does not exceed the given budget. Return the maximum capacity possible within the budget constraints.
Return a single integer representing the maximum total capacity achievable without exceeding the budget.
Example 1
Input
4 30 10 20 50 5 10 20 30 35
Output
40
Explanation
Selecting items with capacity 30 and 10 with costs 5 and 10 respectively gives a total cost of 15, which is within budget 35. Their total capacity is 40, which is maximum under the given budget.