fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int m[45001];
  7. int n, p, i, j;
  8. cin >> n;
  9. for(int i=1;i<=n;i++)
  10. {
  11. cin >> p;
  12. j = i-1;
  13. while(j>0 && p>m[j])
  14. m[j+1] = m[j--];
  15. m[j+1] = p;
  16. cout << j+1 <<endl;
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 3524KB
stdin
6
78
24
68
40
39
89
stdout
1
2
2
3
4
1