#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
static mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define F first
#define S second
constexpr int MAXN = 1e5;
const int LOG = __lg(MAXN)+1;
constexpr int INF = INT_MAX - 10;
constexpr int MOD = 1e9+7;
constexpr double EPS = 1e-8;
void solve(){
int n, k, q;
cin >> n >> k;
vector<int> a(n);
for(int& x: a){
cin >> x;
}
cin >> q;
int t, l, r, m;
ll sum;
while(q--){
sum = 0;
cin >> t;
if (t == 2){
cin >> l >> r >> m;
for(int i = --l; i < r; i++){
sum += 1LL * min(i - l + 1, min(r - i, m)) * a[i];
}
cout << sum << '\n';
} else{
for(int i = 0; i < k; i++){
int x;
cin >> x;
}
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |