#刷题交流# day21刷题打卡 def solution(Q: int, V: int, ships: list) -> int: assert Q == len(ships) obj = [] for m, v, w in ships: p = 1 while p <= m: obj.append([p * v, p * w]) m -= p p <<= 1 if m: obj.append([m * v, m * w]) f = [0 for _ in range(V + 1)] for v, w in obj: for i in range(V, v - 1, -1): f[i] = max(f[i], f[i - v] + w) return f[V]