aboutsummaryrefslogtreecommitdiff
path: root/05_range_queries/static_range_sum_queries_1646.cpp
blob: 7de69a2058fcd8e8639295b56be9b38c433ff84e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <vector>

int main() {
	int n, q, x, y;
	std::cin >> n >> q;
	std::vector<long long> a(n+1, 0);
	for (int i = 1; i <= n; i++) {
		std::cin >> a[i];
		a[i] += a[i-1];
	}

	for (int i = 0; i < q; i++) {
		std::cin >> x >> y;
		std::cout << a[y]-a[x-1] << "\n";
	}
}

Generated with cgit - Back to sebastiano.tronto.net