SHARE
TWEET

BIT CODE

Falak_Ahmed_Shakib Jan 24th, 2020 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const ll Max=2*10e5;
  2.  
  3. ll tree[Max+10];
  4.  
  5. ll query(ll idx)
  6. {
  7.     ll sum=0;
  8.  
  9.     while(idx>0)
  10.     {
  11.         sum+=tree[idx];
  12.  
  13.         idx-= idx & (-idx);
  14.  
  15.     }
  16.  
  17.     return sum;
  18. }
  19.  
  20. void update(ll idx,ll x,ll n)
  21. {
  22.     while(idx<=n)
  23.     {
  24.         tree[idx]+=x;
  25.  
  26.         idx+= idx & (-idx);
  27.     }
  28. }
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