SHARE
TWEET

Untitled

a guest May 23rd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int n, a[1000000];
  5. map<int, int> Map;
  6. vector<int> V;
  7.  
  8. int main() {
  9.     cin >> n;
  10.     for (int i = 1; i <= n; ++i) cin >> a[i];
  11.  
  12.     for (int i = 1; i <= n; ++i) V.push_back(a[i]);
  13.     sort(V.begin(), V.end());
  14.     for (int i = 1; i <= n; ++i) Map[V[i-1]] = i;
  15.     for (int i = 1; i <= n; ++i) a[i] = Map[a[i]];
  16.  
  17.     for (int i = 1; i <= n; ++i) cout << a[i] << " ";
  18.  
  19.     return 0;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top