#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define ar array
#define vc vector
#define aint(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define trav(a,x) for(auto& a : x)
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " = " << x << endl
const int N = 2e5 + 5;
const int L = 24;
const int inf = 1e9 + 7;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
void solve(){
int n, k;
cin >> n >> k;
vc<int>a(n + 1), prs(1 + n, 0), so(1 + n, 0);
rep(i, 1, n + 1){
cin >> a[i];
}
for(int i = 1; i <= n; ++i){
prs[i] = prs[i - 1] + a[i];
so[i] = so[i - 1] + prs[i];
}
if(k == 1){
int q;
cin >> q;
while(q--){
int t, l, r;
cin >> t >> l >> r;
if(t == 1){
int p;
cin >> p;
}else{
int l, r, m;
cin >> l >> r >> m;
int sum = so[r] - so[l + m - 2] - so[r - m];
if(l > 1){
sum += so[l - 2];
}
cout << sum << endl;
}
}
}
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int T = 1;
while(T--){
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... |