提交时间:2024-01-21 09:44:52
运行 ID: 37477
#include <bits/stdc++.h> using namespace std; int a[100005], b[100005]; int main(){ int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; ++ i){ scanf("%d", &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 - i] << '\n'; } return 0; }