fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1e6;
  5. long long a[N], b[N];
  6. int cnt[N];
  7.  
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(false);
  11. int n;
  12. cin >> n;
  13. for (int i = 0; i < n; ++i)
  14. cin >> a[i],
  15. b[i] = a[i];
  16. sort(b, b + n);
  17. for (int i = 0; i < n; ++i)
  18. {
  19. cnt[i] = upper_bound(b, b + n, a[i]) - b;
  20. cout << cnt[i] << " ";
  21. }
  22. cout << "\n";
  23. }
Success #stdin #stdout 0s 22984KB
stdin
6
3 2 3 1 1 2
stdout
6 4 6 2 2 4