쏘ing
[Python] 백준 11659 구간 합 구하기 4 본문
https://www.acmicpc.net/problem/11659

풀이
import sys
n, m = map(int, sys.stdin.readline().rstrip().split())
num_list = list(map(int, sys.stdin.readline().rstrip().split()))
temp = [0]
# 구간 합 구하기
for i in range (n):
temp.append(temp[-1] + num_list[i])
# 구간보다 작은 값 빼기
for i in range (m):
a, b = map(int, sys.stdin.readline().rstrip().split())
print(temp[b] - temp[a-1])
'알고리즘 > CLASS 3' 카테고리의 다른 글
[Python] 백준 1541 잃어버린 괄호 (0) | 2022.02.27 |
---|---|
[Python] 백준 1931 회의실 배정 (0) | 2022.02.26 |
[Python] 백준 2606 바이러스 (0) | 2022.02.26 |
[Python] 백준 1260 DFS와 BFS (0) | 2022.02.26 |
[Python] 백준 11726 2 x n 타일링 (0) | 2022.02.26 |
Comments