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

Envío 1509

Problema 0xde - Ordenar un arreglo grande

  • Autor: d4vsanchez
  • Fecha: 2020-11-02 04:45:01 UTC (Hace alrededor de 4 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.022 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.028 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.027 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.019 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.022 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.021 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.048 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.047 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.045 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.052 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.058 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.083 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.075 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.054 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.082 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.065 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.061 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.058 s 15 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.057 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.048 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.056 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.059 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.056 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.056 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.061 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.058 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 19, in <module>
    sort(arr, 0, n - 1)
NameError: name 'sort' is not defined
0.083 s 14 KBi
Puntos totales: 0 / 100

Código

def generate_partition(arr, low, high):
  i = low - 1
  pivot = arr[high]
  for j in range(low, high):
    if arr[j] <= pivot:
      i = i + 1
      arr[i], arr[j] = arr[j], arr[i]
  arr[i + 1], arr[high] = arr[high], arr[i + 1]
  return i + 1

def quick_sort(arr, low, high):
  if low < high:
    partition = generate_partition(arr, low, high)
    quick_sort(arr, low, partition - 1)
    quick_sort(arr, partition + 1, high)

n = int(input())
arr = [int(x) for x in input().split(" ")]
sort(arr, 0, n - 1)
for i in arr:
  print(i, end = " ")