fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n ; cin>>n;
  7. vector<int>arr(n);
  8. for(int i = 0 ; i<n;i++){
  9. cin>>arr[i];
  10. }
  11. vector<int>pre(n);
  12. pre[0]=0;
  13. for(int j = 1 ; j<n;j++){
  14. for(int i = 0 ; i<j;i++){
  15. if(arr[i]<arr[j]){
  16. pre[j]++;
  17. }
  18. }
  19. }
  20. vector<int>suf(n);
  21. suf[n-1]=0;
  22. for(int j = n-2 ; j>=0;j--){
  23. for(int i = n-2 ; i>j;i--){
  24. if(arr[i]<arr[j]){
  25. suf[j]++;
  26. }
  27. }
  28. }
  29. for(int i =0 ; i<n;i++)cout<<suf[i];
  30. // your code goes here
  31. return 0;
  32. }
Success #stdin #stdout 0s 5304KB
stdin
5
3 2 4 6 5
stdout
10000