Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.016 s | 3 KBi |
#2 |
Correcto
|
0.027 s | 3 KBi |
#3 |
Correcto
|
0.022 s | 3 KBi |
#4 |
Correcto
|
0.026 s | 3 KBi |
#5 |
Correcto
|
0.028 s | 3 KBi |
#6 |
Correcto
|
0.019 s | 3 KBi |
#7 |
Correcto
|
0.018 s | 3 KBi |
#8 |
Correcto
|
0.027 s | 3 KBi |
#9 |
Correcto
|
0.02 s | 3 KBi |
#10 |
Correcto
|
0.02 s | 3 KBi |
#11 |
Correcto
|
0.053 s | 7 KBi |
#12 |
Correcto
|
0.074 s | 7 KBi |
#13 |
Correcto
|
0.088 s | 8 KBi |
#14 |
Correcto
|
0.049 s | 7 KBi |
#15 |
Correcto
|
0.04 s | 7 KBi |
#16 |
Correcto
|
0.038 s | 8 KBi |
#17 |
Correcto
|
0.062 s | 7 KBi |
#18 |
Correcto
|
0.076 s | 7 KBi |
#19 |
Correcto
|
0.051 s | 7 KBi |
#20 |
Correcto
|
0.057 s | 7 KBi |
import sys def sort(array): n = len(array) if n == 0: return [] new_element = array[-1] previous_elements = sort(array[0:-1]) # Now insert last element at the right place. for at in range(len(previous_elements)-1, -1, -1): if previous_elements[at] <= new_element: return previous_elements[0:at+1] + [new_element] + previous_elements[at+1:] return [new_element] + previous_elements if __name__ == "__main__": sys.setrecursionlimit(2000) _ = input() sorted = sort([int(x) for x in input().split()]) print(" ".join([str(x) for x in sorted]))