打卡记录
出租车的最大盈利(动态规划)
链接
class Solution:def maxTaxiEarnings(self, n: int, rides: List[List[int]]) -> int:d = defaultdict(list)for start, end, w in rides:d[end].append((start, end - start + w))f = [0] * (n + 1)for i in range(n):f[i + 1] = f[i]if i + 1 in d:f[i + 1] = max(f[i + 1], max(f[start] + w for start, w in d[i + 1]))return f[-1]