Advertisement
nq1s788

фенвик

Apr 6th, 2024 (edited)
862
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. vector<int> t;
  6.  
  7. int get_p(int x) {
  8.     int answ = 0;
  9.     for (; x >= 0; x = (x & (x + 1)) - 1)
  10.         answ += t[x];
  11.     return answ;
  12. }
  13.  
  14. int get(int l, int r) {
  15.     return get_p(r) - get_p(l - 1);
  16. }
  17.  
  18. void upd(int x) {
  19.     for (; x < n; x |= (x + 1)) tree[x]++;
  20. }
  21.  
  22. int main() {
  23.     int n;
  24.     cin >> n;
  25.     vector<int> a(n);
  26.     for (auto& e : a) cin >> e;
  27.     t.assign(n, 0);
  28.     return 0;
  29. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement