python3求调
查看原帖
python3求调
1227790
MC_xjhjdA楼主2024/12/24 17:47
t,m=map(int,input().split())
ut,we,f=[],[],[[0]*t]*m
for _ in range(m):
    z,zz=map(int,input().split())
    ut.append(z)
    we.append(zz)
for x in range(m):
    for y in range(t):
        f[x][y]=f[x-1][y]
        if y>=ut[x]:
            f[x][y]=max(f[x][y],f[x-1][y-ut[x]]+we[x])
print(f[m-1][t-1])
2024/12/24 17:47
加载中...