fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long n,res[100005];
  4. pair<long long, long long> a[100005];
  5. bool cmp(pair<long long,long long> x, pair<long long,long long> y)
  6. {
  7. return x.first>y.first;
  8. }
  9. int main()
  10. {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(0);
  13. if (fopen("bxh.inp", "r"))
  14. {
  15. freopen("bxh.inp", "r", stdin);
  16. freopen("bxh.out", "w", stdout);
  17. }
  18. cin >> n;
  19. for (long long i=1; i<=n; i++)
  20. {
  21. cin >> a[i].first;
  22. a[i].second=i;
  23. }
  24. sort (a+1,a+1+n,cmp);
  25. res[a[1].second]=1;
  26. for (long long i=2; i<=n; i++)
  27. {
  28. if(a[i].first!=a[i-1].first)
  29. {
  30. res[a[i].second]=i;
  31. }
  32. else
  33. {
  34. res[a[i].second]=res[a[i-1].second];
  35. }
  36. }
  37. for (long long i=1; i<=n; i++)
  38. {
  39. cout << res[i] << " ";
  40. }
  41. }
  42.  
Success #stdin #stdout 0.01s 5712KB
stdin
Standard input is empty
stdout
Standard output is empty