← 返回 walmartlabs 的题目列表Max Profit Investment Plan
类型:online_judge
You have an initial capital W and can make at most K investments. Each investment requires a certain capital and yields a profit. Provide a plan for maximizing profit. Implement the interface: List<int[]> maxProfitPath(int k, int w, int[][] CapitalProfit).
Given:
k: Maximum number of investments.
w: Initial capital.
CapitalProfit: A 2D array where CapitalProfit[i] = [capital_i, profit_i].
Requirement: Return an investment plan achieving maximum profit.
Test case:
Input:
k = 5
w = 10
CapitalProfit = [[0, 10], [5, 20], [10, 5], [12, 15], [15, 30], [20, 25], [30, 40]]
Output: Maximum profit path (format is up to the implementer).
Example
Input
5
10
[[0, 10], [5, 20], [10, 5], [12, 15], [15, 30], [20, 25], [30, 40]]