#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N, M,temp=0; cin >> N >> M;
vector<int>v(N + 1), sum(N+1);
for (int i = 0; i < N; i++) {
cin >> v[i];
temp += v[i];
sum[i + 1] = temp;
}
for (int i = 0; i < M; i++) {
int a, b; cin >> a >> b;
cout << sum[b] - sum[a - 1] <<"\n";
}
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 11720๋ฒ - ์ซ์์ ํฉ (0) | 2021.10.31 |
---|---|
[๋ฐฑ์ค,c++] 11719๋ฒ - ๊ทธ๋๋ก ์ถ๋ ฅํ๊ธฐ2 (0) | 2021.10.31 |
[๋ฐฑ์ค,c++] 11718๋ฒ - ๊ทธ๋๋ก ์ถ๋ ฅํ๊ธฐ (0) | 2021.10.31 |
[๋ฐฑ์ค,c++] 11656๋ฒ - ์ ๋ฏธ์ฌ ๋ฐฐ์ด (0) | 2021.10.31 |
[๋ฐฑ์ค,c++] 11652๋ฒ - ์นด๋ (0) | 2021.10.31 |
[๋ฐฑ์ค,c++] 11651๋ฒ - ์ขํ ์ ๋ ฌํ๊ธฐ2 (0) | 2021.10.28 |
๋๊ธ