#include <bits/stdc++.h>
using namespace std;
int n, numPerm, q;
#define MAX_N 100'100
int a[MAX_N + 2];
int id[12];
long long pre[MAX_N + 2];
#undef MAX_N
int main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);
// freopen("test.inp","r",stdin);
// freopen("test.out","w",stdout);
cin >> n >> numPerm;
pre[0] = 0;
for (int i = 1; i <= n; ++i) cin >> a[i], pre[i] = pre[i - 1] + a[i];
cin >> q;
while (q--) {
int type;
cin >> type;
if (type == 1) {
for (int i = 1; i <= numPerm; ++i) cin >> id[i];
} else {
int L, R, range;
cin >> L >> R >> range;
if (R - L + 1 < range) {cout << "0\n"; continue;}
long long ans = 0;
for (int i = L; i + range - 1 <= R; ++i) ans += pre[i + range - 1] - pre[i - 1];
cout << ans << "\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... |