Skip to content

Instantly share code, notes, and snippets.

@mym0404
Created June 14, 2022 06:22
Show Gist options
  • Save mym0404/4b5b34dd7d85c0f84caf297144c0b8fe to your computer and use it in GitHub Desktop.
Save mym0404/4b5b34dd7d85c0f84caf297144c0b8fe to your computer and use it in GitHub Desktop.
# 입력 받기
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n):
a[i] += a[i - 1]
for i in range(m):
l, r = map(int, input().split())
# 0-based 인덱스로 처리해주기 위해
l -= 1
r -= 1
print(a[r] - (a[l - 1] if l > 0 else 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment