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>
#define int long long
using namespace std;
int32_t main () {
int n, k;
cin >> n >> k;
int arr[n+1];
for(int i = 1;i<=n;i++) {
cin >> arr[i];
}
int q;
cin >> q;
while(q--) {
int k;
cin >> k;
if(k == 1) {
int d;
cin >> d;
}
else {
int ans = 0;
int l, r, m;
cin >> l >> r >> m;
m = min(r-l+2 - m, m);
for(int i = l;i<=r;i++) {
ans += min(min(i-l+1, r-i+1), m)*arr[i];
}
cout<<ans<<endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |