Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #define _CRT_SECURE_NO_WARNINGS
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <string>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <vector>
- #include <stdio.h>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <deque>
- #include <ctime>
- #include <iomanip>
- #include <bitset>
- #include <unordered_map>
- #include <unordered_set>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- #define mh() make_heap()
- #define poph() pop_heap()
- #define pushh() push_heap()
- #define sor(n) n.begin(), n.end()
- #define rsor(n) n.rbegin(), n.rend()
- #define mp make_pair
- #define files freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout)
- #define p(T) pair<T,T>
- #define toch(x) cout.precision(x), cout.setf(ios::fixed)
- #define znac(l) abs(l)/l
- #define IOS ios::sync_with_stdio(false)
- #define IOSB cin.tie(0), cout.tie(0);
- const ll ok = ll(1e9 + 7);
- const ll N = 131072;
- ll tree[(N+1) * 2];
- ll check(ll v)
- {
- ll ans = 0;
- v += N-1;
- ans += tree[v];
- for (v = v >> 1; v; v = v >> 1)
- ans += tree[v];
- return ans;
- }
- void sumot(ll v,ll tl, ll tr, ll l, ll r, ll val)
- {
- if (l > r)
- return;
- if (tl == l&&tr == r)
- {
- tree[v] += val;
- }
- else
- {
- ll tm = (tr + tl) >> 1;
- sumot(v << 1, tl, tm, l, min(tm, r), val);
- sumot((v << 1) + 1, tm + 1, tr, max(tm + 1, l), r, val);
- }
- }
- int main()
- {
- IOSB;
- IOS;
- #ifdef TheCompiler
- files;
- #endif
- ll n;
- cin >> n;
- ll a, b, c;
- cin >> a >> b >> c;
- sumot(1, 1, N, a, b, c);
- for (int i = 1; i <= n; i++)
- {
- cin >> a >> b >> c;
- sumot(1, 1, N, a, b, c);
- }
- for (int i = 1; i <= n; i++)
- {
- cout << check(i) << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement