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 ent '\n'
#define fi first
#define se second
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int inf = (int)(1e9 + 7);
const ll INF = (ll)(2e18 + 7);
const ld eps = (ld)(1e-12);
const int dx[] = { -1,0,1,0,1,1,-1,-1 }, dy[] = { 0,1,0,-1,1,-1,1,-1 };
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
int n,k;
ll pref[N];
void solve(){
cin>>n>>k;
for(int i=1;i<=n;i++){
int x;
cin>>x;
pref[i]=pref[i-1]+x;
}
int q;
cin>>q;
while(q--){
int tp;
cin>>tp;
if(tp==1){
int x;
cin>>x;
}
else{
int l,r,m;
cin>>l>>r>>m;
int cnt=min(m,r-l+1-m+1);
ll ans=0;
for(int i=1;i<=cnt;i++){
ans+=pref[r]-pref[l-1];
l++;
r--;
}
cout<<ans<<ent;
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
srand(time(0));
//freopen(".in", "r", stdin);
//freopen(".out","w",stdout);
int ttt=1;
//cin>>ttt;
for(int i=1;i<=ttt;i++){
//cout<<"NEWCASE"<<ent;
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |