Untitled
unknown
plain_text
2 years ago
465 B
4
Indexable
#include <iostream> #include<iomanip> #include<cmath> #include<string> #include<numeric> #include <algorithm> using namespace std; int main() { int n; cin >> n; int a[1000001]; for (int i=1; i <= n; i++) { cin >> a[i]; } int m; cin >> m; int l; int r; for (int i = 0; i < m; i++) { cin >> l >> r; int s[1000001]; s[0] = 0; int k = 0; for (int i = 1; i <= n; i++) { k = k + a[i]; s[i] = k; } cout << s[r] - s[l - 1]<<'\n'; } }
Editor is loading...
Leave a Comment