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>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define bismillah ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
using namespace std;
const int N = 1e5+7;
int a[N], pref[N];
int getsum(int l, int r, int m){
int ret = 0;
for(int i=l+m-1, b=l; i<=r; i++, b++){
ret+=(pref[i]-pref[b-1]);
}return ret;
}
signed main(){
bismillah;
int n, k; cin >> n >> k;
for(int i=1; i<=n; i++){
cin >> a[i];
}
for(int i=1; i<=n; i++){
pref[i] = pref[i-1]+a[i];
}
int q; cin >> q;
while(q--){
int t; cin >> t;
if(t==1){
// k=1 > will remain unchanged
int x; cin >> x;
}else{
int l, r, m; cin >> l >> r >> m;
cout << getsum(l, r, m) << '\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... |