Advertisement
Josif_tepe

Untitled

Sep 30th, 2023
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <queue>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <iostream>
  6. #include <set>
  7. #include <cstring>
  8. #include <stack>
  9. #include <algorithm>
  10. #include <map>
  11. #include <cmath>
  12. //#include <bits/stdc++.h>
  13. using namespace std;
  14. typedef long long ll;
  15. const int maxn = 3e5 + 10;
  16. const ll INF = 3e16 + 10;
  17.  
  18. struct node {
  19.     int sum, cnt;
  20.    
  21.     node() {}
  22.     node(int _sum, int _cnt) {
  23.         sum = _sum;
  24.         cnt = _cnt;
  25.     }
  26.    
  27. };
  28. node segment_tree[3 * maxn];
  29. node my_merge(node A, node B) {
  30.     return node(A.sum + B.sum, A.cnt + B.cnt);
  31. }
  32. node query(int L, int R, int pos, int i, int j) {
  33.     // L R i L R j L R
  34.     if(i <= L and R <= j) {
  35.         return segment_tree[pos];
  36.     }
  37.     if(R < i or j < L) {
  38.         return node(0, 0);
  39.     }
  40.     int mid = (L + R) / 2;
  41.     return my_merge(query(L, mid, 2 * pos, i, j), query(mid + 1, R, 2 * pos + 1, i, j));
  42. }
  43.  
  44.  
  45. int main() {
  46.     ios_base::sync_with_stdio(false);
  47.    
  48.     return 0;
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement