daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void add(int ind, int v)
  2. {
  3.     for (int i = ind; i < N; i += i&-i)
  4.         t[i] += v;
  5. }
  6.  
  7.  
  8. int get(int ind)
  9. {
  10.     if (ind <= 0)
  11.         return 0;
  12.    
  13.     int cnt = 0;
  14.     for (int i = ind; i; i -= i&-i)
  15.         cnt += t[i];
  16.    
  17.     return cnt;
  18. }
  19.  
  20.  
  21. int get(int l, int r)
  22. {
  23.     return get(r) - get(l - 1);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top