https://www.acmicpc.net/problem/11659
import sys
N, M = map(int, input().split())
data = list(map(int, sys.stdin.readline().split()))
sum_value = 0
prefix_sum = [0]
for k in data:
sum_value += k
prefix_sum.append(sum_value)
for prefix in range(M):
i, j = map(int, sys.stdin.readline().split())
print(prefix_sum[j] - prefix_sum[i - 1])
'Python > Baekjoon' 카테고리의 다른 글
백준 6603번 : 로또 (0) | 2022.11.14 |
---|---|
백준 1759번 : 암호 만들기 (0) | 2022.11.14 |
백준 4948번 : 베르트랑 공준 (0) | 2022.10.18 |
백준 1929번 : 소수 구하기 (0) | 2022.10.18 |
백준 11653번 : 소인수분해 (0) | 2022.10.17 |