Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.029 s | 3 KBi |
#2 |
Correcto
|
0.024 s | 3 KBi |
#3 |
Correcto
|
0.023 s | 3 KBi |
#4 |
Correcto
|
0.025 s | 3 KBi |
#5 |
Correcto
|
0.029 s | 3 KBi |
#6 |
Correcto
|
0.025 s | 3 KBi |
#7 |
Correcto
|
0.146 s | 11 KBi |
#8 |
Correcto
|
0.147 s | 11 KBi |
#9 |
Correcto
|
0.138 s | 11 KBi |
#10 |
Correcto
|
0.156 s | 12 KBi |
#11 |
Correcto
|
0.184 s | 15 KBi |
#12 |
Correcto
|
0.192 s | 15 KBi |
#13 |
Correcto
|
0.175 s | 15 KBi |
#14 |
Correcto
|
0.206 s | 15 KBi |
#15 |
Correcto
|
0.18 s | 15 KBi |
#16 |
Correcto
|
0.301 s | 15 KBi |
#17 |
Correcto
|
0.333 s | 15 KBi |
#18 |
Correcto
|
0.224 s | 14 KBi |
#19 |
Correcto
|
0.235 s | 14 KBi |
#20 |
Correcto
|
0.162 s | 11 KBi |
#21 |
Correcto
|
0.241 s | 14 KBi |
#22 |
Correcto
|
0.207 s | 15 KBi |
#23 |
Correcto
|
0.196 s | 15 KBi |
#24 |
Correcto
|
0.24 s | 15 KBi |
#25 |
Correcto
|
0.233 s | 15 KBi |
#26 |
Correcto
|
0.171 s | 14 KBi |
#27 |
Correcto
|
0.23 s | 14 KBi |
import heapq def mergesort(arr, num_elements): if num_elements > 1: pivot = num_elements // 2 left = mergesort(arr[:pivot], pivot) right = mergesort(arr[pivot:], num_elements - pivot) merged = [] while left and right: lowest = left.pop(0) if left[0] < right[0] else right.pop(0) merged.append(lowest) merged.extend(left) merged.extend(right) return merged else: return arr def heapsort(arr, num_elements): _ = heapq.heapify(arr) return [heapq.heappop(arr) for _ in range(num_elements)] if __name__ == "__main__": num_elements = int(input()) arr = list(map(int, input().split(' '))) # Use a different sort every minute sorts = [mergesort, heapsort] sort_idx = -1 sorted_arr = sorts[sort_idx](arr, num_elements) print(' '.join(map(str, sorted_arr)))