#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<long long> prefix(N + 1, 0);
for (int i = 1; i <= N; ++i) {
prefix[i] = prefix[i - 1] + A[i - 1];
}
vector<long long> prefix_prefix(N + 2, 0);
for (int i = 1; i <= N; ++i) {
prefix_prefix[i] = prefix_prefix[i - 1] + prefix[i];
}
int Q;
cin >> Q;
while (Q--) {
int type;
cin >> type;
if(type==1) {int x;cin >> x;}
if (type == 2) {
int l, r, m;
cin >> l >> r >> m;
if (m > (r - l + 1)) {
cout << 0 << '\n';
continue;
}
int k = r - m + 1;
long long term1 = prefix_prefix[r] - prefix_prefix[l + m - 2];
long long term2 = prefix_prefix[r - m] - prefix_prefix[l - 2];
long long total = term1 - term2;
cout << total << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |