提交时间:2024-01-21 10:01:52

运行 ID: 37480

#include <bits/stdc++.h> using namespace std; int a[1000005], b[1000005]; int main(){ int n, m; cin >> n; cin >> m; for (int i = 1; i <= n; ++ i){ cin >> a[i]; b[i] = b[i - 1] + a[i]; } for (int i = 1; i <= m; ++ i){ int l, r; cin >> l >> r; cout << b[r] - b[l - 1] << '\n'; } return 0; }