Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.97 KB | None | 0 0
  1. /*
  2. █████████████.....██████....██.........█....██████████....██.........██.
  3. ██.........██.......██......█.█........█....██......██.....██.......██..
  4. ██.........██.......██......█..█.......█....██......██......██.....██...
  5. ██.........██.......██......█...█......█....██......██.......██...██....
  6. ██.........██.......██......█....█.....█....██......██........██.██.....
  7. ██.........██.......██......█.....█....█....██......██.........███......
  8. █████████████.......██......█.....█....█....██████████.........███......
  9. ██..................██......█......█...█....██......██.........███......
  10. ██..................██......█......█...█....██......██.........███......
  11. ██..................██......█.......█..█....██......██.........███......
  12. ██..................██......█.......█..█....██......██.........███......
  13. ██..................██......█........█.█....██......██.........███......
  14. ██..................██......█........█.█....██......██.........███......
  15. ██................██████....█.........██....██......██.........███......
  16. ЗАПУСКАЕМ
  17. ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
  18. ▄███▀░◐░░░▌░░░░░░░
  19. ░░░░▌░░░░░▐░░░░░░░
  20. ░░░░▐░░░░░▐░░░░░░░
  21. ░░░░▐░░░░░▐░░░░░░░
  22. ░░░░▐░░░░░▐░░░░░░░
  23. ░░░░▐░░░░░▐░░░░░░░
  24. ░░░░▐░░░░░▐░░░░░░░
  25. ░░░░▐░░░░░▐░░░░░░░
  26. ░░░░▐░░░░░▐░░░░░░░
  27. ░░░░▐░░░░░▐░░░░░░░
  28. ░░░░▌░░░░░▐▄▄░░░░░
  29. ░░░░▌░░░░▄▀▒▒▀▀▀▀▄
  30. ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
  31. ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
  32. ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
  33. ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
  34. ░░░░░░░░░░░▌▌░▌▌░░░░░
  35. ░░░░░░░░░░░▌▌░▌▌░░░░░
  36. ░░░░░░░░░▄▄▌▌▄▌▌░░░░░
  37.  */
  38. #include <iostream>
  39. #include <vector>
  40. #include <algorithm>
  41. #include <iomanip>
  42. #include <tuple>
  43. #include <math.h>
  44. #include <set>
  45. #include <stack>
  46. #include <bitset>
  47. #include <map>
  48. #include <queue>
  49. #include <random>
  50. //#define DEBUG
  51. #define pqueue priority_queue
  52. #define pb(x) push_back(x)
  53. #define all(x) x.begin(), x.end()
  54. #define int long long
  55. #define  mk(a, b) make_pair(a, b)
  56. //#define x first;
  57. //#define y second;
  58.  
  59. using namespace std;
  60.  
  61. typedef long long ll;
  62. typedef unsigned long long ull;
  63. typedef long double ld;
  64. typedef vector<int> vi;
  65. typedef vector<vector<int> > vvi;
  66. typedef vector<ull> vull;
  67. typedef vector<ll> vll;
  68. typedef tuple<int, int, int> tiii;
  69. typedef pair<int, int> pii;
  70. typedef vector<pair<int, int> > vpii;
  71. typedef vector<bool> vb;
  72. typedef vector<string> vs;
  73. typedef vector< vector<int> > vvi;
  74. typedef vector<char> vc;
  75.  
  76. const int INF = 1e9;
  77. const ll INFLL = 1e12;
  78. const int MOD = 1000000007;
  79. const ld eps = 1e-6;
  80. const int MOD2 = (1<<30)+1;
  81. const int dosz = 5e5;
  82.  
  83. void fast_io(){
  84.     ios_base::sync_with_stdio(0);
  85.     cin.tie(0);
  86.     cout.tie(0);
  87. #ifdef DEBUG
  88. //    freopen("a.in", "r", stdin);
  89. #else
  90. //        freopen("rsq2.in", "r", stdin);
  91. //        freopen("rsq2.out", "w", stdout);
  92. #endif
  93. }
  94.  
  95.  
  96. struct tree{
  97.     int lb, rb;
  98.     int sum = 0;
  99.     tree *l = 0, *r = 0;
  100.  
  101.     tree (int _lb, int _rb){
  102.         lb = _lb, rb = _rb;
  103.     }
  104.  
  105.     void extend(){
  106.         if(!l && lb+1<rb) {
  107.             int mid = (lb + rb) / 2;
  108.             l = new tree(lb, mid);
  109.             r = new tree(mid, rb);
  110.         }
  111.     }
  112.     void add(int k, int x){
  113.         extend();
  114.         sum += x;
  115.         if(l){
  116.             if(k<l->rb)
  117.                 l->add(k, x);
  118.             else
  119.                 r->add(k, x);
  120.         }
  121.     }
  122.     int get_sum(int lq, int rq){
  123.         if(lq<=lb && rb<=rq)
  124.             return sum;
  125.         else if(max(lq, lb)>=min(rq, rb))
  126.             return 0;
  127.         extend();
  128.         return l->get_sum(lq, rq)+r->get_sum(lq, rq);
  129.     }
  130. };
  131.  
  132. void solve(){
  133.     tree kek = tree(0, 1e18);
  134.     kek.add(1e7, 1e5);
  135.     cout << kek.get_sum(0, 1e6) << endl;
  136.     cout << kek.get_sum(0, 1e9) << endl;
  137. }
  138.  
  139. signed main() {
  140.     fast_io();
  141.     int q = 1;
  142.     while(q--){
  143.         solve();
  144.     }
  145.     return 0;
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement