Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <queue>
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <iostream>
- #include <set>
- #include <cstring>
- #include <stack>
- #include <algorithm>
- #include <map>
- #include <cmath>
- //#include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int maxn = 3e5 + 10;
- const ll INF = 3e16 + 10;
- struct node {
- int sum, cnt;
- node() {}
- node(int _sum, int _cnt) {
- sum = _sum;
- cnt = _cnt;
- }
- };
- node segment_tree[3 * maxn];
- node my_merge(node A, node B) {
- return node(A.sum + B.sum, A.cnt + B.cnt);
- }
- node query(int L, int R, int pos, int i, int j) {
- // L R i L R j L R
- if(i <= L and R <= j) {
- return segment_tree[pos];
- }
- if(R < i or j < L) {
- return node(0, 0);
- }
- int mid = (L + R) / 2;
- return my_merge(query(L, mid, 2 * pos, i, j), query(mid + 1, R, 2 * pos + 1, i, j));
- }
- int main() {
- ios_base::sync_with_stdio(false);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement