Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.028 s | 3 KBi |
#2 |
Correcto
|
0.024 s | 3 KBi |
#3 |
Correcto
|
0.018 s | 3 KBi |
#4 |
Correcto
|
0.034 s | 10 KBi |
#5 |
Correcto
|
0.036 s | 3 KBi |
#6 |
Correcto
|
0.029 s | 3 KBi |
#7 |
Correcto
|
0.791 s | 7 KBi |
#8 |
Correcto
|
0.475 s | 13 KBi |
#9 |
Correcto
|
0.56 s | 5 KBi |
#10 |
Correcto
|
0.72 s | 12 KBi |
#11 |
Correcto
|
0.586 s | 14 KBi |
#12 |
Correcto
|
0.662 s | 14 KBi |
#13 |
Correcto
|
0.615 s | 15 KBi |
#14 |
Correcto
|
0.565 s | 15 KBi |
#15 |
Correcto
|
0.822 s | 23 KBi |
#16 |
Correcto
|
0.826 s | 15 KBi |
#17 |
Correcto
|
0.646 s | 18 KBi |
#18 |
Correcto
|
0.614 s | 16 KBi |
#19 |
Correcto
|
0.676 s | 14 KBi |
#20 |
Correcto
|
0.49 s | 9 KBi |
#21 |
Correcto
|
0.518 s | 14 KBi |
#22 |
Correcto
|
0.962 s | 14 KBi |
#23 |
Correcto
|
0.667 s | 19 KBi |
#24 |
Correcto
|
0.531 s | 15 KBi |
#25 |
Correcto
|
0.647 s | 15 KBi |
#26 |
Correcto
|
0.632 s | 15 KBi |
#27 |
Correcto
|
0.66 s | 17 KBi |
import random def exchange(array, i, j): array[i], array[j] = array[j], array[i] def insertion_sort(array, lo, hi): for i in range(lo, hi + 1): j = i while j > 0 and array[j] < array[j-1]: array[j], array[j - 1] = array[j - 1], array[j] j -= 1 def hoare_partition(array, lo, hi): i = lo j = hi + 1 pivot = array[lo] while True: i += 1 while array[i] < pivot: i += 1 if i == hi: break j -= 1 while array[j] > pivot: j -= 1 if j == lo: break if i >= j: break exchange(array, j, i) exchange(array, lo, j) return j def sort(array, lo, hi): if hi <= lo: return if hi - lo <= 10: insertion_sort(array, lo, hi) else: j = hoare_partition(array, lo, hi) sort(array, lo, j - 1) sort(array, j + 1, hi) n = int(input()) array = [int(x) for x in input().split()] random.shuffle(array) # To avoid worst case scenario sort(array, 0, n - 1) print(*array)