题解 | 称砝码
n=int(input()) weights=list(map(int,input().split())) numbers=list(map(int,input().split())) all_weights={0} list1=[] for i in range(n):#1numbers[i]weights[i] for j in range(numbers[i]):#4 list1.append(weights[i]) for i in range(len(list1)): for j in list(all_weights): all_weights.add(list1[i]+j) all_weights1=set(all_weights) print(len(all_weights1)) 注意存的结果是集合,没有使用列表,集合没有根据位置索引 使用列表会有重复,会内存溢出