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 f first
#define s second
#define int long long
#define pii pair<int,int>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7; // !
int t, n, q, a[N], tree[N];
void upd(int ind,int val) {
for(ind;ind <= n; ind += ind & (-ind)) tree[ind] += val;
}
int get(int ind) {
int ans = 0;
for(ind; ind >= 1; ind -= (ind) & (-ind)) ans += tree[ind];
return ans;
}
main(){
int K;
cin >> n >> K;
if(K > 1) return 0;
for(int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1], upd(i,a[i]);
int q;
cin >> q;
while(q--) {
int t;
cin >> t;
if(t == 1) {
int x;
cin >> x;
continue;
}
int l,r,m;
cin >> l >> r >> m;
cout << get(r) - get(l + m - 2) - (get(r - m) - get(l - 2)) << endl;
}
}
Compilation message (stderr)
Main.cpp: In function 'void upd(long long int, long long int)':
Main.cpp:10:6: warning: statement has no effect [-Wunused-value]
10 | for(ind;ind <= n; ind += ind & (-ind)) tree[ind] += val;
| ^~~
Main.cpp: In function 'long long int get(long long int)':
Main.cpp:14:6: warning: statement has no effect [-Wunused-value]
14 | for(ind; ind >= 1; ind -= (ind) & (-ind)) ans += tree[ind];
| ^~~
Main.cpp: At global scope:
Main.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main(){
| ^~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |