Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.024 s | 3 KBi |
#2 |
Correcto
|
0.024 s | 3 KBi |
#3 |
Correcto
|
0.034 s | 3 KBi |
#4 |
Correcto
|
0.032 s | 3 KBi |
#5 |
Correcto
|
0.033 s | 3 KBi |
#6 |
Correcto
|
0.028 s | 3 KBi |
#7 |
Tiempo límite excedido
|
0.534 s | 13 KBi |
#8 |
Correcto
|
0.676 s | 13 KBi |
#9 |
Tiempo límite excedido
|
0.606 s | 11 KBi |
#10 |
Tiempo límite excedido
|
0.599 s | 9 KBi |
#11 |
Correcto
|
0.505 s | 17 KBi |
#12 |
Correcto
|
0.51 s | 16 KBi |
#13 |
Correcto
|
0.462 s | 16 KBi |
#14 |
Correcto
|
0.465 s | 16 KBi |
#15 |
Correcto
|
0.468 s | 16 KBi |
#16 |
Correcto
|
0.842 s | 16 KBi |
#17 |
Correcto
|
0.835 s | 17 KBi |
#18 |
Tiempo límite excedido
|
0.495 s | 16 KBi |
#19 |
Tiempo límite excedido
|
0.446 s | 14 KBi |
#20 |
Correcto
|
0.723 s | 13 KBi |
#21 |
Correcto
|
0.508 s | 15 KBi |
#22 |
Correcto
|
0.512 s | 16 KBi |
#23 |
Correcto
|
0.501 s | 16 KBi |
#24 |
Correcto
|
0.493 s | 16 KBi |
#25 |
Correcto
|
0.483 s | 16 KBi |
#26 |
Correcto
|
0.516 s | 15 KBi |
#27 |
Correcto
|
0.53 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 while i < len(left) or j < len(right): 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 return result if __name__ == "__main__": n = input() arr = list(map(int, input().split(" "))) print(" ".join(map(str, mergesort(arr))))