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

Envío 3622

Problema 0xde - Ordenar un arreglo grande

  • Autor: jocarmp08
  • Fecha: 2021-04-04 04:08:49 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.028 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.027 s 8 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.039 s 8 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.029 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.016 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.022 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.051 s 5 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.054 s 7 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.052 s 5 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.066 s 9 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.063 s 14 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.069 s 14 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.091 s 14 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.052 s 14 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.067 s 14 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.049 s 14 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.069 s 14 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.055 s 16 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.067 s 14 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.05 s 5 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.07 s 14 KBi
#22
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.067 s 14 KBi
#23
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.063 s 14 KBi
#24
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.065 s 15 KBi
#25
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.069 s 15 KBi
#26
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.088 s 14 KBi
#27
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 53, in <module>
    random.shuffle(array)  # To avoid worst case scenario
NameError: name 'random' is not defined
0.073 s 16 KBi
Puntos totales: 0 / 100

Código

def exchange(array, i, j):
    array[i], array[j] = array[j], array[i]


def insertion_sort(array):
    for i in range(len(array)):
        j = i
        while j > 0 and array[j] < array[j-1]:
            array[j], array[j - 1] = array[j - 1], array[j]
            j -= 1


def hoare_partition(array, lo, hi):
    i = lo
    j = hi + 1
    pivot = array[lo]

    while True:
        i += 1
        while array[i] < pivot:
            i += 1
            if i == hi:
                break

        j -= 1
        while array[j] > pivot:
            j -= 1
            if j == lo:
                break

        if i >= j:
            break

        exchange(array, j, i)

    exchange(array, lo, j)
    return j


def sort(array, lo, hi):
    if hi <= lo:
        return
    if hi - lo <= 7:
        insertion_sort(array)
    else:
        j = hoare_partition(array, lo, hi)
        sort(array, lo, j - 1)
        sort(array, j + 1, hi)


n = int(input())
array = [int(x) for x in input().split()]
random.shuffle(array)  # To avoid worst case scenario
sort(array, 0, n - 1)
print(*array)