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

Envío 5763

Problema 0xde - Ordenar un arreglo grande

  • Autor: Franchesco
  • Fecha: 2022-02-25 14:49:30 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.022 s 3 KBi
#2
Correcto
0.023 s 3 KBi
#3
Correcto
0.018 s 3 KBi
#4
Correcto
0.017 s 3 KBi
#5
Correcto
0.022 s 3 KBi
#6
Correcto
0.014 s 3 KBi
#7
Tiempo límite excedido
1.533 s 4 KBi
#8
Tiempo límite excedido
1.546 s 7 KBi
#9
Tiempo límite excedido
1.526 s 4 KBi
#10
Tiempo límite excedido
1.575 s 9 KBi
#11
Tiempo límite excedido
1.507 s 13 KBi
#12
Tiempo límite excedido
1.564 s 14 KBi
#13
Tiempo límite excedido
1.533 s 14 KBi
#14
Tiempo límite excedido
1.503 s 14 KBi
#15
Tiempo límite excedido
1.562 s 14 KBi
#16
Tiempo límite excedido
1.542 s 14 KBi
#17
Tiempo límite excedido
1.522 s 14 KBi
#18
Tiempo límite excedido
1.573 s 15 KBi
#19
Tiempo límite excedido
1.573 s 14 KBi
#20
Tiempo límite excedido
1.575 s 4 KBi
#21
Tiempo límite excedido
1.583 s 14 KBi
#22
Tiempo límite excedido
1.507 s 17 KBi
#23
Tiempo límite excedido
1.537 s 14 KBi
#24
Tiempo límite excedido
1.576 s 15 KBi
#25
Tiempo límite excedido
1.549 s 15 KBi
#26
Tiempo límite excedido
1.581 s 14 KBi
#27
Tiempo límite excedido
1.512 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 - 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)