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;
const int nmax = 1e5+5;
int A[nmax];
long long pref[nmax];
int main() {
int N,K,Q;
cin >> N >> K;
pref[0] = 0;
for(int i=1; i<=N; i++) {
cin >> A[i];
pref[i] = A[i]+pref[i-1];
}
cin >> Q;
int com,l,r,m;
long long sum;
while(Q--) {
cin >> com;
sum = 0;
if(com==1) {
cin >> m;
} else {
cin >> l >> r >> m;
if(m > (r-l+1)/2) m = (r-l+1)-m+1;
for(int i=0; i<m; i++) {
sum+=(pref[r-i]-pref[l+i-1]);
}
cout << sum << endl;
}
}
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... |