第31行不能这么写,改成这样应该就行
dp = [[0 for i in range(W+1)] for i in range(n+1)]