문제 확인하기
2. 정답 코드 (Python, memory: 31256KB, time: 80ms)
def find_note_number(N, time_list, query_list):
result = []
cumulative_time = [0] * N
for i in range(N):
cumulative_time[i] = time_list[i] if i == 0 else cumulative_time[i-1] + time_list[i]
for t in query_list:
for i in range(N):
if t < cumulative_time[i]:
result.append(i + 1)
break
return result
N, Q = map(int, input().split())
time_list = [int(input()) for _ in range(N)]
query_list = [int(input()) for _ in range(Q)]
result = find_note_number(N, time_list, query_list)
for note_number in result:
print(note_number)