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
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main(){
int n,k;
cin>>n>>k;
int arr[n+5],pre[n+5];
pre[0]=0;
for(int i=1;i<=n;i++){
cin>>arr[i];
pre[i]=pre[i-1]+arr[i];
}
int q;
cin>>q;
while(q--){
int a;
cin>>a;
if(a==1){
int b[k];
for(int i=0;i<k;i++)cin>>b[i];
}
else{
int x,y,z;
cin>>x>>y>>z;
int s=pre[x+z-1]-pre[x-1];
int ans=s;
for(int i=x+z;i<=y;i++){
s+=arr[i];
s-=arr[i-z];
ans+=s;
}
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... |