题解 | 音符

音符

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

import bisect

n,q = map(int,input().split())
b = list(map(int,input().split()))
t = list(map(int,input().split()))

# 计算每个音符的起始时刻
music = [0]*(n)
for i in range(1,n):
    music[i] = music[i-1]+b[i-1]

# 二分法查找位置
for e in t:
    print(bisect.bisect_right(music,e))


全部评论

相关推荐

10-13 13:49
南京大学 财务
饿魔:笑死我了,你简直是个天才
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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