orazma

q.cpp

Apr 11th, 2026
49
0
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <map>
  5. #include <climits>
  6. #include <set>
  7. #include <numeric>
  8. #include <cmath>
  9. #include <string>
  10. #include <cstdlib>
  11. #define f first
  12. #define s second
  13.  
  14. #define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  15.  
  16. using namespace std;
  17. const int MAXN = 2e5 + 10;
  18. vector <int> t(4 * MAXN, -1);
  19.  
  20. void update(int v, int tl, int tr, int pos, int val){
  21.     if (tl > tr){
  22.         return;
  23.     }
  24.     if (tl == tr){
  25.         t[v] = val;
  26.         return;
  27.     }
  28.     int tm = (tl + tr) >> 1;
  29.     if (pos <= tm){
  30.         update(v << 1, tl, tm, pos, val);
  31.     }
  32.     else{
  33.         update((v << 1) | 1, tm + 1, tr, pos, val);
  34.     }
  35.     t[v] = max(t[v << 1], t[(v << 1) | 1]);
  36. }
  37.  
  38. int get_max(int v, int tl, int tr, int l, int r){
  39.     if (l > r)
  40.         return -1;
  41.     if (tl == l && tr == r){
  42.         return t[v];
  43.     }
  44.     int tm = (tl + tr) >> 1;
  45.     return max(get_max(v << 1, tl, tm, l, min(r, tm)),
  46.                get_max((v << 1) | 1, tm + 1, tr, max(tm + 1, l), r));
  47. }
  48. pair <string, pair <int, int> > q[MAXN];
  49.  
  50. int main() {
  51.     IOS;
  52.     int tt;
  53.     cin >> tt;
  54.     vector <pair <int, int> > vec;
  55.     vec.push_back({0, 0});
  56.     for (int i = 1; i <= tt; i++){
  57.         cin >> q[i].f >> q[i].s.f >> q[i].s.s;
  58.         if (q[i].f == "add"){
  59.             vec.push_back(q[i].s);
  60.         }
  61.     }
  62.     int m = vec.size();
  63.  
  64.     sort(vec.begin(), vec.end());
  65.  
  66.     for (int i = 1; i <= tt; i++){
  67.         if (q[i].f == "add"){
  68.             int x = q[i].s.f;
  69.             int y = q[i].s.s;
  70.             int pos = int(lower_bound(vec.begin(), vec.end(), make_pair(x, y)) - vec.begin()) + 1;
  71.             update(1, 1, m, pos, y);
  72.         }
  73.         else if (q[i].f == "remove"){
  74.             int x = q[i].s.f;
  75.             int y = q[i].s.s;
  76.             int pos = int(lower_bound(vec.begin(), vec.end(), make_pair(x, y)) - vec.begin()) + 1;
  77.             update(1, 1, m, pos, -1);
  78.         }
  79.         else if (q[i].f == "find"){
  80.             int x = q[i].s.f;
  81.             int y = q[i].s.s;
  82.             int pos = int(lower_bound(vec.begin(), vec.end(), make_pair(x + 1, -1)) - vec.begin()) + 1;
  83.  
  84.             int left = pos;
  85.             int right = m;
  86.             int ans = -1;
  87.             while(left <= right){
  88.                 int mid = (left + right) / 2;
  89.                 if (get_max(1, 1, m, pos, mid) > y){
  90.                     ans = mid;
  91.                     right = mid - 1;
  92.                 }
  93.                 else{
  94.                     left = mid + 1;
  95.                 }
  96.             }
  97.             if (ans == -1){
  98.                 cout << -1 << "\n";
  99.             }
  100.             else{
  101.                 cout << vec[ans - 1].f << ' ' << vec[ans - 1].s << "\n";
  102.             }
  103.         }
  104.     }
  105.  
  106.     return 0;
  107. }
  108.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Falholnu
    18 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Lorutovym
    14 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • Varmyrdy
    2 days
    # CSS 0.45 KB | 0 0
    1. ⭐ Changelly Profit Exploit Documentation ⭐
    2.  
    3. https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=fxxxuskbcr
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment