1 动态规划
dp[i][j]表示前i个项目中做j个项目带来的最大收益
需要先对所有的项目按照启动资本排序
但是结果超时了:32 / 35 个通过测试用例
class Solution:
def findMaximizedCapital(self, k: int, w: int, profits: List[int], capital: List[int]) -> int:
n = len(profits)
tasks = [(capital[i], profits[i]) for i in range(n)]
tasks.sort(key=lambda x: x[0])
# dp[i][j]表示前i个项目中做j个项目带来的最大收益
dp, max_first = [[0] * (k + 1) for _