题解 | 称砝码
称砝码
https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c
while True: try: n=int(input()) weight=list(map(int,input().split())) num=list(map(int,input().split())) arr=[] for i in range(len(num)): arr.extend([weight[i] for _ in range(num[i])]) dp=set() dp.add(0) for i in arr: dpcopy=dp.copy() for j in dpcopy: dp.add(j+i) print(len(dp)) except: break