Skip to content

Commit db718d7

Browse files
committed
Alhamdulillah
1 parent 9f8e05b commit db718d7

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

List Removals.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
#include <ext/pb_ds/assoc_container.hpp>
4+
using namespace __gnu_pbds;
5+
6+
// template <typename Key, typename Mapped, typename Compare, typename Tag,
7+
// typename Policy>
8+
// class tree;
9+
10+
#define ll long long
11+
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag,
12+
tree_order_statistics_node_update>
13+
indexed_multiset;
14+
15+
int main() {
16+
ll n, ans, k, ind = 0;
17+
cin >> n;
18+
ll x;
19+
20+
indexed_multiset ms;
21+
22+
for (ll i = 1; i <= n; i++) {
23+
cin >> x;
24+
ms.insert({ind++, x});
25+
}
26+
27+
vector<ll> vans;
28+
29+
for (ll i = 1; i <= n; i++) {
30+
cin >> x;
31+
auto it = ms.find_by_order(x - 1);
32+
vans.push_back(it->second);
33+
ms.erase(it);
34+
}
35+
36+
for (auto x : vans)
37+
cout << x << " ";
38+
39+
return 0;
40+
}

0 commit comments

Comments
 (0)