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

Envío 3630

Problema 0xcf - Mirando al horizonte

  • Autor: jocarmp08
  • Fecha: 2021-04-04 07:04:50 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.019 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 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.03 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 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.024 s 6 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.044 s 8 KBi
#5
Correcto
0.025 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 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.732 s 44 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.778 s 45 KBi
#8
Correcto
0.907 s 71 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.825 s 46 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 31, in <module>
    looking_to_the_horizon(array, number_of_cases)
  File "script.py", line 14, in looking_to_the_horizon
    result[prev_building_index] = current_building_height
IndexError: list assignment index out of range
0.815 s 58 KBi
Puntos totales: 30 / 100

Código

from collections import deque


def looking_to_the_horizon(array, n):
    result = [-1 for _ in range(n)]
    stack = deque(maxlen=n)

    for current_building_index, current_building_height in enumerate(array):
        while len(stack) > 0:
            # Get previous building info from the stack
            prev_building_index, prev_building_height = stack[len(stack) - 1]
            if prev_building_height < current_building_height:
                # If previous building height is lower than current building height, update results
                result[prev_building_index] = current_building_height
                stack.pop()
            else:
                break

        # Push the current building info to the stack
        stack.append((current_building_index, current_building_height))

    return result


number_of_cases = int(input())
for i in range(number_of_cases):
    array_size = int(input())
    array = [int(x) for x in input().split()]
    print("Case #{0}: {1}".format(
        i + 1, ' '.join(map(str, looking_to_the_horizon(array, array_size)))))
looking_to_the_horizon(array, number_of_cases)