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;
int main(){
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int q;
cin>>q;
int sums[q];
int u = 0;
if(k==1){
for(int i=0;i<q;i++){
int x;
cin>>x;
if(x==1){
int y;
cin>>y;
}
else{
int l,r,m;
cin>>l>>r>>m;
int s = 0;
int d = r-l+1;
for(int j=l-1; j<=r; j++){
int p = j-l+2;
if(p<m){
s+=a[j]*p;
}
else if(d-p+1<m){
s+=a[j]*(d-p+1);
}
else{
s+=a[j]*m;
}
}
sums[u] = s;
u++;
}
}
}
for(int i=0;i<u;i++){
cout<<sums[i]<<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... |