Advertisement
Anwar_Rizk

Untitled

Sep 18th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/tree_policy.hpp>
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #pragma GCC target("fpmath=387") //Turns on excess precision
  5.  
  6. using namespace std;
  7. using namespace __gnu_pbds;
  8.  
  9. #define EPS 1e-9
  10. #define PI acos(-1)
  11. #define ll long long
  12. #define Mod 1'000'000'007
  13. #define INF 2'000'000'000
  14. #define sz(x) int(x.size())
  15. #define all(s) s.begin(), s.end()
  16. #define rall(s) s.rbegin(), s.rend()
  17. #define Num_of_Digits(n) ((int)log10(n)+1)
  18. #define to_decimal(bin) stoll(bin, nullptr, 2)
  19. #define fixed(n) cout << fixed << setprecision(n)
  20. #define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  21. #define cout(st) for(auto& i : st) cout << i << " "; cout << "\n"
  22. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << " : " << s << "\n"
  23. #define matrix(grid, n, m) vector < vector <int> > grid(n, vector <int> (m));
  24. #define cout_2d(grid) for(auto& v : grid){for(auto& x : v) cout << x << " "; cout << "\n";}
  25. #define cin_2d(grid, n, m) for(int i=0; i<n; i++) for(int j=0; j<m && cin >> grid[i][j]; j++);
  26. #define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>
  27. #define multi_ordered_set tree<int, null_type, greater_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
  28.  
  29. template < typename T = int > using Pair = pair < T, T >; //Pair<int> p;
  30.  
  31. template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
  32. for (auto &x: v) in >> x;
  33. return in;
  34. }
  35.  
  36. template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
  37. for (const T &x: v) out << x << ' ';
  38. return out;
  39. }
  40.  
  41. void Anwar_Rizk(){
  42. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  43. #ifndef ONLINE_JUDGE
  44. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  45. #endif
  46. }
  47.  
  48. void solve(){
  49. int n;
  50. cin >> n;
  51. vector < int > v(n), ans;
  52. cin >> v;
  53. multi_ordered_set st;
  54. reverse(all(v));
  55. for(auto& i : v){
  56. ans.push_back(st.order_of_key(i));
  57. st.insert(i);
  58. }
  59. reverse(all(ans));
  60. cout << ans;
  61. }
  62.  
  63. int main()
  64. { Anwar_Rizk();
  65.  
  66. int t = 1;
  67. //cin >> t;
  68. while(t--){
  69. solve();
  70. }
  71.  
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement