This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long n, k;
cin >> n >> k;
vector<long long> prefixsums;
prefixsums.push_back(0);
for (long long i = 0; i < n; i++) {
long long a; cin >> a;
prefixsums.push_back(a + prefixsums[i]);
}
long long q; cin >> q;
for (long long i = 0; i < q; i++) {
long long a; cin >> a;
if (a == 1) {
for (long long j = 0; j < k; j++) {
long long b; cin >> b;
}
} else {
long long l, r, m, s=0; cin >> l >> r >> m;
for (long long j = 0; j < min(m, (r-l+1)/2); j++) {
s += prefixsums[r+1] - prefixsums[l+1];
l++;
r--;
}
cout << s << "\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |