█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5766

Problema 0xde - Ordenar un arreglo grande

  • Autor: Franchesco
  • Fecha: 2022-02-25 15:17:23 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.033 s 7 KBi
#2
Correcto
0.013 s 3 KBi
#3
Correcto
0.026 s 3 KBi
#4
Correcto
0.024 s 3 KBi
#5
Correcto
0.027 s 3 KBi
#6
Correcto
0.023 s 3 KBi
#7
Tiempo límite excedido
1.552 s 4 KBi
#8
Tiempo límite excedido
1.58 s 7 KBi
#9
Tiempo límite excedido
1.568 s 4 KBi
#10
Tiempo límite excedido
1.545 s 8 KBi
#11
Tiempo límite excedido
1.575 s 13 KBi
#12
Tiempo límite excedido
1.535 s 14 KBi
#13
Tiempo límite excedido
1.568 s 14 KBi
#14
Tiempo límite excedido
1.517 s 16 KBi
#15
Tiempo límite excedido
1.574 s 14 KBi
#16
Tiempo límite excedido
1.563 s 14 KBi
#17
Tiempo límite excedido
1.532 s 14 KBi
#18
Tiempo límite excedido
1.513 s 15 KBi
#19
Tiempo límite excedido
1.523 s 15 KBi
#20
Tiempo límite excedido
1.543 s 4 KBi
#21
Tiempo límite excedido
1.579 s 14 KBi
#22
Tiempo límite excedido
1.573 s 14 KBi
#23
Tiempo límite excedido
1.557 s 14 KBi
#24
Tiempo límite excedido
1.559 s 15 KBi
#25
Tiempo límite excedido
1.531 s 15 KBi
#26
Tiempo límite excedido
1.592 s 14 KBi
#27
Tiempo límite excedido
1.507 s 14 KBi
Puntos totales: 23 / 100

Código

length = int(input())

my_array = list(map(int, input().split()))


def heapify(my_array, length):
    i = length // 2 - 1
    while i >= 0:
        if i * 2 + 1 < length:
            if my_array[i] < my_array[i * 2 + 1]:
                my_array[i], my_array[i * 2 + 1] = my_array[i * 2 + 1], my_array[i]
        if i * 2 + 2 < length:
            if my_array[i] < my_array[i * 2 + 2]:
                my_array[i], my_array[i * 2 + 2] = my_array[i * 2 + 2], my_array[i]
        i -= 1


def heap_sort(my_array, length):
    if length:
        heapify(my_array, length)
        my_array[0], my_array[length - 1] = my_array[length - 1], my_array[0]
        heap_sort(my_array, length - 1)

heap_sort(my_array, length)

print(*my_array)