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

Envío 1400

Problema 0xdd - Ordenar un arreglo pequeño

  • Autor: Mejibyte
  • Fecha: 2020-10-25 04:53:09 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.019 s 3 KBi
#2
Incorrecto
0.02 s 3 KBi
#3
Incorrecto
0.027 s 3 KBi
#4
Incorrecto
0.029 s 3 KBi
#5
Incorrecto
0.022 s 3 KBi
#6
Incorrecto
0.024 s 3 KBi
#7
Incorrecto
0.028 s 3 KBi
#8
Incorrecto
0.026 s 3 KBi
#9
Incorrecto
0.02 s 3 KBi
#10
Incorrecto
0.028 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.049 s 8 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>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.054 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.041 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.04 s 8 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>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.038 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.043 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.038 s 8 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>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.055 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 19, in <module>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.04 s 8 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>
    sorted = sort([int(x) for x in input().split()])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  File "script.py", line 7, in sort
    previous_elements = sort(array[0:-1])
  [Previous line repeated 994 more times]
  File "script.py", line 3, in sort
    print(n)
RecursionError: maximum recursion depth exceeded while getting the str of an object
0.042 s 7 KBi
Puntos totales: 0 / 100

Código

def sort(array):
  n = len(array)
  print(n)
  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]))