orazma

N.cpp

Apr 11th, 2026
48
0
Never
12
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define s second
  3. #define f first
  4. #define lb lower_bound
  5. #define pb push_back
  6. #define endl "\n"
  7. #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  8. using namespace std;
  9. const int mod1 = 1e9 + 7;
  10. const int mod2 = 676767677;
  11. const int MAXN = 2e5 + 5;
  12. const int INF = 1e9 + 7;
  13.  
  14. int t[4 * MAXN], cnt[MAXN], p[MAXN], q[MAXN], ans[MAXN];
  15.  
  16. void build(int v, int tl, int tr, int val){
  17.     if (tl > tr){
  18.         return;
  19.     }
  20.     if (tl == tr){
  21.         t[v] = val;
  22.         return;
  23.     }
  24.     int tm = (tl + tr) >> 1;
  25.     build(v << 1, tl, tm, val);
  26.     build((v << 1) | 1, tm + 1, tr, val);
  27.     t[v] = t[v << 1] + t[(v << 1) | 1];
  28. }
  29. int get(int v, int tl, int tr, int l, int r){
  30.     if (l > r){
  31.         return 0;
  32.     }
  33.     if (tl == l && tr == r){
  34.         return t[v];
  35.     }
  36.     int tm = (tl + tr) >> 1;
  37.     return get((v << 1), tl, tm, l, min(r, tm))
  38.         + get((v << 1) | 1, tm + 1, tr, max(l, tm + 1), r);
  39. }
  40.  
  41. void update(int v, int tl, int tr, int pos, int val){
  42.     if (tl > tr)
  43.         return;
  44.     if (tl == tr){
  45.         t[v] = val;
  46.         return;
  47.     }
  48.     int tm = (tl + tr) >> 1;
  49.     if (pos <= tm){
  50.         update(v << 1, tl, tm, pos, val);
  51.     }
  52.     else{
  53.         update((v << 1) | 1, tm + 1, tr, pos, val);
  54.     }
  55.     t[v] = t[v << 1] + t[(v << 1) | 1];
  56. }
  57. void ord(int a[], int n){
  58.     build(1, 1, n, 1);
  59.     for (int i = 1; i <= n; i++){
  60.         cnt[n - i] += get(1, 1, n, 1, a[i]);
  61.         update(1, 1, n, a[i] + 1, 0);
  62.     }
  63. }
  64.  
  65. void solve_problem() {
  66.  
  67.     int n;
  68.     cin >> n;
  69.  
  70.     for (int i = 1; i <= n; i++){
  71.         cin >> p[i];
  72.     }
  73.  
  74.     for (int i = 1; i <= n; i++){
  75.         cin >> q[i];
  76.     }
  77.     ord(p, n);
  78.     ord(q, n);
  79.  
  80.     for (int i = 1; i <= n; i++){
  81.         if (cnt[i] >= i + 1){
  82.             cnt[i] -= i + 1;
  83.             cnt[i + 1]++;
  84.         }
  85.     }
  86.     build(1, 1, n, 1);
  87.     for (int i = n - 1; i >= 0; i--){
  88.         int answer = -1;
  89.         int left = 0;
  90.         int right = n;
  91.         while (left <= right){
  92.             int mid = (left + right) >> 1;
  93.             if (get(1, 1, n, 1, mid) > cnt[i]){
  94.                 answer = mid;
  95.                 right = mid - 1;
  96.             }
  97.             else{
  98.                 left = mid + 1;
  99.             }
  100.         }
  101.         ans[n - i] = answer;
  102.         update(1, 1, n, ans[n - i], 0);
  103.     }
  104.  
  105.     for (int i = 1; i <= n; i++){
  106.         cout << ans[i] - 1 << ' ';
  107.     }
  108. }
  109.  
  110. signed main () {
  111.     IOS
  112.  
  113.     //freopen("sum.in", "r", stdin);
  114.     //freopen("sum.out", "w", stdout);
  115.  
  116.     int tt = 1;
  117.     //cin >> tt;
  118.  
  119.     while (tt--) {
  120.       solve_problem();
  121.     }
  122. }
  123.  
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=iybjelahdy
    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