Created
June 14, 2022 06:22
-
-
Save mym0404/4b5b34dd7d85c0f84caf297144c0b8fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 입력 받기 | |
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