Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.031 s | 3 KBi |
#2 |
Correcto
|
0.035 s | 3 KBi |
#3 |
Correcto
|
0.034 s | 3 KBi |
#4 |
Correcto
|
0.023 s | 3 KBi |
#5 |
Correcto
|
0.032 s | 3 KBi |
#6 |
Correcto
|
0.025 s | 3 KBi |
#7 |
Tiempo límite excedido
|
1.039 s | 5 KBi |
#8 |
Tiempo límite excedido
|
1.016 s | 7 KBi |
#9 |
Tiempo límite excedido
|
1.011 s | 6 KBi |
#10 |
Tiempo límite excedido
|
1.026 s | 9 KBi |
#11 |
Correcto
|
0.767 s | 14 KBi |
#12 |
Correcto
|
0.924 s | 13 KBi |
#13 |
Incorrecto
|
0.975 s | 12 KBi |
#14 |
Incorrecto
|
0.772 s | 12 KBi |
#15 |
Incorrecto
|
0.911 s | 13 KBi |
#16 |
Tiempo límite excedido
|
1.068 s | 12 KBi |
#17 |
Tiempo límite excedido
|
1.096 s | 12 KBi |
#18 |
Tiempo límite excedido
|
1.059 s | 12 KBi |
#19 |
Tiempo límite excedido
|
1.062 s | 12 KBi |
#20 |
Tiempo límite excedido
|
1.049 s | 5 KBi |
#21 |
Incorrecto
|
0.926 s | 12 KBi |
#22 |
Incorrecto
|
0.803 s | 12 KBi |
#23 |
Incorrecto
|
0.807 s | 12 KBi |
#24 |
Tiempo límite excedido
|
1.002 s | 12 KBi |
#25 |
Tiempo límite excedido
|
1.051 s | 12 KBi |
#26 |
Tiempo límite excedido
|
1.045 s | 12 KBi |
#27 |
Incorrecto
|
0.952 s | 12 KBi |
def merge_sort(a): """ Merge sort technique """ middle = int(len(a) // 2) left = a[:middle] right = a[middle:] if middle > 0: merge_sort(left) merge_sort(right) ms_helper(a, left, right) def ms_helper(a, left, right): """ Helper function """ 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 def main(): """ Using Merge sort """ n = int(input()) integers = input() a = integers.split(" ") merge_sort(a) a = " ".join(str(number) for number in a) print(a) if __name__ == "__main__": main()