Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int read(int idx){
- int sum = 0;
- while (idx <= MaxVal){
- sum += tree[idx];
- idx += (idx & -idx);
- }
- return sum;
- }
- void update(int idx ,int val){
- while (idx > 0){
- tree[idx] += val;
- idx -= (idx & -idx);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement