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;
#define ll long long
int main(){
int n,k;
cin>>n>>k;
ll a[n+1],p1[n+1],p2[n+1];
a[0]=p1[0]=p2[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
p1[i]=p1[i-1]+a[i];
p2[i]=p2[i-1]+p1[i];
}
int q;
cin>>q;
while(q--){
int t;
cin>>t;
if(t==2){
int l,r,m;
cin>>l>>r>>m;
ll ans=p2[r]-p2[l+m-2]-p2[r-m];
if(l>1)ans+=p2[l-2];
cout<<ans<<'\n';
}else{
int x[k];
for(int i=0;i<k;i++)cin>>x[i];
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |