Editorial for Goat II
Use this editorial only when stuck, and do not copy-paste code from it.
Please be respectful to the problem author and editorialist. Submitting an official solution before solving the problem yourself is a bannable offence.
Author:kahootist
Editorial
n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
c[0] = a[0]
for i in range(1, n):
c[i] = c[i-1] + a[i]
for query in b:
l = 0
r = n
while l < r:
m = (l + r) // 2
if c[m] > query:
r = m
else:
l = m + 1
print(r, end=" ")
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.