Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.02 s | 3 KBi |
#2 |
Correcto
|
0.029 s | 3 KBi |
#3 |
Correcto
|
0.022 s | 3 KBi |
#4 |
Correcto
|
0.022 s | 3 KBi |
#5 |
Correcto
|
0.023 s | 3 KBi |
#6 |
Correcto
|
0.021 s | 3 KBi |
#7 |
Correcto
|
0.416 s | 13 KBi |
#8 |
Correcto
|
0.585 s | 13 KBi |
#9 |
Correcto
|
0.547 s | 13 KBi |
#10 |
Correcto
|
0.683 s | 14 KBi |
#11 |
Correcto
|
0.413 s | 16 KBi |
#12 |
Correcto
|
0.418 s | 16 KBi |
#13 |
Correcto
|
0.43 s | 15 KBi |
#14 |
Correcto
|
0.453 s | 15 KBi |
#15 |
Correcto
|
0.437 s | 15 KBi |
#16 |
Correcto
|
0.802 s | 17 KBi |
#17 |
Correcto
|
0.73 s | 16 KBi |
#18 |
Correcto
|
0.442 s | 16 KBi |
#19 |
Correcto
|
0.476 s | 16 KBi |
#20 |
Correcto
|
0.6 s | 13 KBi |
#21 |
Correcto
|
0.465 s | 15 KBi |
#22 |
Correcto
|
0.459 s | 16 KBi |
#23 |
Correcto
|
0.46 s | 16 KBi |
#24 |
Correcto
|
0.459 s | 16 KBi |
#25 |
Correcto
|
0.473 s | 16 KBi |
#26 |
Correcto
|
0.457 s | 15 KBi |
#27 |
Correcto
|
0.476 s | 15 KBi |
def mergesort(arr): if len(arr) < 2: return arr mid = len(arr) // 2 left = mergesort(arr[:mid]) right = mergesort(arr[mid:]) return merge(left, right) def merge(left, right): result = [] i, j = 0, 0 try: while True: if left[i] <= right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j += 1 if i == len(left) or j == len(right): result.extend(left[i:] or right[j:]) break except: result = result + left[i:] + right[j:] return result if __name__ == "__main__": n = input() arr = list(map(int, input().split(" "))) print(" ".join(map(str, mergesort(arr))))