fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class FenwickTree {
  5. vector<int> bit;
  6. int n;
  7.  
  8. public:
  9. FenwickTree(int size) : n(size), bit(size + 1, 0) {}
  10.  
  11. void update(int index, int delta) {
  12. for (++index; index <= n; index += index & -index)
  13. bit[index] += delta;
  14. }
  15.  
  16. int query(int index) {
  17. int sum = 0;
  18. for (++index; index > 0; index -= index & -index)
  19. sum += bit[index];
  20. return sum;
  21. }
  22.  
  23. int rangeQuery(int left, int right) {
  24. return query(right) - query(left - 1);
  25. }
  26. };
  27.  
  28. int main() {
  29. // your code goes here
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty