Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.018 s | 3 KBi |
#2 |
Correcto
|
0.027 s | 5 KBi |
#3 |
Correcto
|
0.026 s | 3 KBi |
#4 |
Correcto
|
0.028 s | 8 KBi |
#5 |
Correcto
|
0.026 s | 5 KBi |
#6 |
Correcto
|
0.03 s | 3 KBi |
#7 |
Correcto
|
0.446 s | 5 KBi |
#8 |
Correcto
|
0.474 s | 7 KBi |
#9 |
Incorrecto
|
0.574 s | 5 KBi |
#10 |
Incorrecto
|
0.566 s | 9 KBi |
#11 |
Correcto
|
0.563 s | 14 KBi |
#12 |
Correcto
|
0.62 s | 19 KBi |
#13 |
Incorrecto
|
0.866 s | 16 KBi |
#14 |
Incorrecto
|
0.653 s | 15 KBi |
#15 |
Incorrecto
|
0.496 s | 14 KBi |
#16 |
Incorrecto
|
0.684 s | 14 KBi |
#17 |
Incorrecto
|
0.533 s | 14 KBi |
#18 |
Incorrecto
|
0.561 s | 14 KBi |
#19 |
Incorrecto
|
0.561 s | 15 KBi |
#20 |
Correcto
|
0.486 s | 5 KBi |
#21 |
Incorrecto
|
0.574 s | 15 KBi |
#22 |
Incorrecto
|
0.626 s | 14 KBi |
#23 |
Incorrecto
|
0.586 s | 14 KBi |
#24 |
Incorrecto
|
0.557 s | 15 KBi |
#25 |
Incorrecto
|
0.616 s | 15 KBi |
#26 |
Incorrecto
|
0.485 s | 15 KBi |
#27 |
Incorrecto
|
0.607 s | 15 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): 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)