发达
2023-12-25 21:15:32
发布于:浙江
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int N = 1e5 + 10;
int a[N],s[N];
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++ ) cin >> a[i];
for (int i = 1; i <= n; i ++ ) s[i] = s[i - 1] + a[i];
while (m -- )
{
int l,r;
cin >> l >> r;
cout << s[r] - s[l - 1] << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个