题解 | #称砝码#

称砝码

https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c

n = int(input())

weights = list(map(int, input().split()))

nums = list(map(int ,input().split()))

res = {0,}

all = []

for i in range(n):
    for j in range(nums[i]):
        all.append(weights[i])

for i in all:
    for j in list(res):  # 在迭代res不能改变res的大小,加list()转换成临时的list则可以改变原来的res
        res.add(i+j)

print(len(res))


全部评论

相关推荐

06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
zhch7:建议9✌️把学历加黑加粗,如果实在offer可能是觉得佬不会去
投了多少份简历才上岸
点赞 评论 收藏
分享
完美的潜伏者许愿简历...:隐藏信息被你提取出来了,暗示,这就是暗示
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务