Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.026 s | 3 KBi |
#2 |
Correcto
|
0.026 s | 3 KBi |
#3 |
Correcto
|
0.026 s | 3 KBi |
#4 |
Correcto
|
0.027 s | 3 KBi |
#5 |
Correcto
|
0.024 s | 3 KBi |
#6 |
Correcto
|
0.037 s | 3 KBi |
#7 |
Correcto
|
0.828 s | 5 KBi |
#8 |
Tiempo límite excedido
|
1.028 s | 8 KBi |
#9 |
Tiempo límite excedido
|
1.074 s | 5 KBi |
#10 |
Tiempo límite excedido
|
1.1 s | 9 KBi |
#11 |
Correcto
|
0.845 s | 14 KBi |
#12 |
Correcto
|
0.936 s | 13 KBi |
#13 |
Incorrecto
|
0.761 s | 12 KBi |
#14 |
Incorrecto
|
0.803 s | 12 KBi |
#15 |
Tiempo límite excedido
|
1.039 s | 12 KBi |
#16 |
Tiempo límite excedido
|
1.031 s | 12 KBi |
#17 |
Tiempo límite excedido
|
1.018 s | 12 KBi |
#18 |
Incorrecto
|
0.808 s | 12 KBi |
#19 |
Tiempo límite excedido
|
1.084 s | 12 KBi |
#20 |
Tiempo límite excedido
|
1.024 s | 5 KBi |
#21 |
Incorrecto
|
0.877 s | 12 KBi |
#22 |
Incorrecto
|
0.991 s | 12 KBi |
#23 |
Tiempo límite excedido
|
1.034 s | 12 KBi |
#24 |
Tiempo límite excedido
|
1.016 s | 12 KBi |
#25 |
Incorrecto
|
0.959 s | 12 KBi |
#26 |
Incorrecto
|
0.944 s | 12 KBi |
#27 |
Incorrecto
|
0.863 s | 12 KBi |
def merge_sort(): n = int(input()) integers = input() a = integers.split(" ") ms_sort(a) a = " ".join(str(number) for number in a) print(a) def ms_sort(a): middle = int(len(a) // 2) left = a[:middle] right = a[middle:] if middle > 0: ms_sort(left) ms_sort(right) ms_merge(a, left, right) def ms_merge(a, left, right): iA = iLeft = iRight = 0 while iLeft < len(left) and iRight < len(right): if left[iLeft] < right[iRight]: a[iA] = left[iLeft] iLeft += 1 else: a[iA] = right[iRight] iRight += 1 iA +=1 while iLeft < len(left): a[iA] = left[iLeft] iLeft += 1 iA += 1 while iRight < len(right): a[iA] = right[iRight] iRight += 1 iA += 1 if __name__ == "__main__": merge_sort()