fork download
  1. t = int(input())
  2.  
  3. l = []
  4.  
  5. for i in range(t):
  6. n = int(input())
  7. l.append(n)
  8.  
  9. def qs(l):
  10. if len(l) < 2: return l
  11. may = []
  12. men = []
  13. piv = l[0]
  14. for i in range(1, len(l)):
  15. if l[i] > piv:
  16. may.append(l[i])
  17. else: men.append(l[i])
  18. return qs(men) + [piv] + qs(may)
  19.  
  20. def res(l):
  21. for i in range(len(l)):
  22. print(l[i])
  23.  
  24. res(qs(l)) # your code goes here
Success #stdin #stdout 0.08s 13980KB
stdin
5
5
3
6
7
1
stdout
1
3
5
6
7