Advertisement
Saksham_Sahgal

Untitled

Apr 7th, 2022
1,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstring>
  3. #include<vector>
  4. #include<set>
  5. #include<map>
  6. #include<algorithm>
  7. #include<cmath>
  8. #include<climits>
  9.  
  10. #include <ext/pb_ds/assoc_container.hpp> // Common file
  11. #include <ext/pb_ds/tree_policy.hpp> // Including
  12.  
  13. #define lli long long int
  14. #define GO_FAST ios_base::sync_with_stdio(0);ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  15. // basic debugging macros
  16. lli __i__,__j__;
  17. lli inf = 9e18;
  18. #define line_printer(l) cout<<"\n"; for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl;
  19. #define array_printer(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<"\n";
  20. #define array_2d_printer(a,r,c) cout<<"\n"<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<"\n";}
  21. using namespace std;
  22. using namespace __gnu_pbds;
  23.  
  24. typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
  25. typedef tree<lli,null_type,less_equal<lli>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
  26.  
  27. int main()
  28. {
  29.     //GO_FAST
  30.     //freopen("input.txt", "r", stdin);
  31.     //freopen("myout.txt", "w", stdout);
  32.     lli n;
  33.     cin>>n;
  34.     lli a[n];
  35.     lli b[n];
  36.     ordered_multiset x;
  37.     for(int i=0;i<n;i++)
  38.         cin>>a[i];
  39.  
  40.     for(int i=n-1;i>=0;i--)
  41.     {
  42.         x.insert(a[i]);
  43.         b[i] = (x.order_of_key(a[i]));
  44.     }
  45.  
  46.     array_printer(b,n);
  47.     return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement