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
const ll maxn = 1e5+7;
ll n,k,q,tre,tz,l,r,m;
ll pre[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n>>k;
for(ll i = 0; i<n; i++){
cin>>tre;
pre[i+1]=pre[i]+tre;
}
cin>>q;
for(ll i = 0;i<q; i++){
cin>>tre;
if(tre==1){
cin>>l;
}
else{
cin>>l>>r>>m;
ll od = 0;
int f = min(m,(r-l+1)-m+1);
for(ll p = 0; p<f; p++){
od+=pre[r]-pre[l-1];
r--;
l++;
}
cout<<od<<'\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |