题解 | #小A的文化节#

小A的文化节

https://ac.nowcoder.com/acm/contest/78306/A

# 读取输入
n, m = map(int, input().split())  # 项目总数,小A参加的项目数
happiness = list(map(int, input().split()))  # 每个项目的欢乐度
attended_projects = list(map(int, input().split()))  # 小A参加的项目编号

# 计算小A的总欢乐度
total_happiness = sum(happiness[i - 1] for i in attended_projects)

# 输出结果
print(total_happiness)
全部评论

相关推荐

04-30 15:51
已编辑
上海交通大学 机械工程师
点赞 评论 收藏
分享
03-13 16:51
已编辑
门头沟学院 硬件开发
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客企业服务