📅  最后修改于: 2022-03-11 14:59:04.252000             🧑  作者: Mango
def max_independant_weight(weights):
def with_and_without(i):
if i >= len(weights):
return 0, 0
left = with_and_without(2*i + 1)
right = with_and_without(2*i + 2)
return (weights[i] + left[1] + right[1],
max(left) + max(right))
return max(with_and_without(0))