Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int MAXN = 1e5;
- int n, aib[1 + MAXN];
- void update(int x, int t) {
- for (int i = x; i <= n; i += i & -i)
- aib[i] += t;
- }
- int query(int x) {
- int ans = 0;
- for (int i = x; i > 0; i -= i & -i)
- ans += aib[i];
- return ans;
- }
- int query_interval(int l, int r) {
- return query(r) - query(l - 1);
- }
Add Comment
Please, Sign In to add comment