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

Envío 1510

Problema 0xde - Ordenar un arreglo grande

  • Autor: d4vsanchez
  • Fecha: 2020-11-02 04:45:17 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.022 s 3 KBi
#2
Correcto
0.023 s 3 KBi
#3
Correcto
0.023 s 3 KBi
#4
Correcto
0.029 s 3 KBi
#5
Correcto
0.021 s 3 KBi
#6
Correcto
0.028 s 3 KBi
#7
Tiempo límite excedido
0.987 s 5 KBi
#8
Tiempo límite excedido
0.761 s 7 KBi
#9
Tiempo límite excedido
0.64 s 5 KBi
#10
Tiempo límite excedido
0.731 s 9 KBi
#11
Tiempo límite excedido
1.086 s 14 KBi
#12
Tiempo límite excedido
1.028 s 14 KBi
#13
Tiempo límite excedido
0.836 s 14 KBi
#14
Tiempo límite excedido
0.614 s 14 KBi
#15
Tiempo límite excedido
0.626 s 14 KBi
#16
Correcto
0.531 s 14 KBi
#17
Correcto
0.531 s 14 KBi
#18
Tiempo límite excedido
0.572 s 15 KBi
#19
Tiempo límite excedido
0.468 s 14 KBi
#20
Tiempo límite excedido
1.012 s 5 KBi
#21
Tiempo límite excedido
1.065 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>
    quick_sort(arr, 0, n - 1)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  [Previous line repeated 9 more times]
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  [Previous line repeated 981 more times]
  File "script.py", line 13, in quick_sort
    partition = generate_partition(arr, low, high)
  File "script.py", line 4, in generate_partition
    for j in range(low, high):
RecursionError: maximum recursion depth exceeded in comparison
0.402 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>
    quick_sort(arr, 0, n - 1)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  [Previous line repeated 9 more times]
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  [Previous line repeated 981 more times]
  File "script.py", line 13, in quick_sort
    partition = generate_partition(arr, low, high)
  File "script.py", line 4, in generate_partition
    for j in range(low, high):
RecursionError: maximum recursion depth exceeded in comparison
0.438 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>
    quick_sort(arr, 0, n - 1)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  [Previous line repeated 9 more times]
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  [Previous line repeated 981 more times]
  File "script.py", line 13, in quick_sort
    partition = generate_partition(arr, low, high)
  File "script.py", line 4, in generate_partition
    for j in range(low, high):
RecursionError: maximum recursion depth exceeded in comparison
0.445 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>
    quick_sort(arr, 0, n - 1)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  File "script.py", line 15, in quick_sort
    quick_sort(arr, partition + 1, high)
  [Previous line repeated 9 more times]
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  File "script.py", line 14, in quick_sort
    quick_sort(arr, low, partition - 1)
  [Previous line repeated 981 more times]
  File "script.py", line 13, in quick_sort
    partition = generate_partition(arr, low, high)
  File "script.py", line 4, in generate_partition
    for j in range(low, high):
RecursionError: maximum recursion depth exceeded in comparison
0.433 s 15 KBi
#26
Tiempo límite excedido
0.861 s 14 KBi
#27
Tiempo límite excedido
0.717 s 14 KBi
Puntos totales: 30 / 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(" ")]
quick_sort(arr, 0, n - 1)
for i in arr:
  print(i, end = " ")