#include <bits/stdc++.h>
#define nn '\n'
#define int long long
#define pb push_back
#define all(x) x.begin() + 1, x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec std::vector
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vec<int> a(n + 1), p(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
p[0] = 0;
for (int i = 1; i <= n; i++) {
p[i] = p[i - 1] + a[i];
//cout << p[i]<< ' ';
}
int q;
cin >> q;
while (q--) {
int type;
cin >> type;
if (type == 1) {
int k;
cin >> k;
} else {
int l, r, m;
cin >> l >> r >> m;
int sum = 0;
if (r - l + 1 < m) {
cout << 0 << nn;
continue;
}
for (int i = l; i + m - 1 <= r; i++) {
sum += p[i + m - 1] - p[i - 1];
}
cout << sum << nn;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |