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

Envío 1401

Problema 0xdd - Ordenar un arreglo pequeño

  • Autor: Mejibyte
  • Fecha: 2020-10-25 04:53:39 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.027 s 3 KBi
#2
Correcto
0.02 s 3 KBi
#3
Correcto
0.029 s 3 KBi
#4
Correcto
0.024 s 3 KBi
#5
Correcto
0.027 s 3 KBi
#6
Correcto
0.019 s 3 KBi
#7
Correcto
0.021 s 3 KBi
#8
Correcto
0.022 s 3 KBi
#9
Correcto
0.022 s 3 KBi
#10
Correcto
0.021 s 3 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.034 s 7 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.041 s 8 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.052 s 8 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.051 s 7 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.041 s 8 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.053 s 8 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.042 s 7 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.047 s 8 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.039 s 7 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 18, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 6, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 995 more times]
  File "script.py", line 2, in sort
    n = len(array)
RecursionError: maximum recursion depth exceeded while calling a Python object
0.051 s 7 KBi
Puntos totales: 50 / 100

Código

def sort(array):
  n = len(array)
  if n == 0:
    return []
  new_element = array[-1]
  previous_elements = sort(array[0:-1])

  # Find last element in previous_elements that is
  # Now insert last element at the right place.
  for at in range(len(previous_elements)-1, -1, -1):
      if previous_elements[at] <= new_element:
        return previous_elements[0:at+1] + [new_element] + previous_elements[at+1:]

  return [new_element] + previous_elements

if __name__ == "__main__":
  _ = input()
  sorted = sort([int(x) for x in input().split()])
  print(" ".join([str(x) for x in sorted]))