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

Envío 441

Problema 0xcf - Mirando al horizonte

  • Autor: Katorea132
  • Fecha: 2020-09-04 16:08:34 UTC (Hace alrededor de 1 año)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.022 s 3 KBi
#2
Correcto
0.026 s 3 KBi
#3
Correcto
0.027 s 3 KBi
#4
Correcto
0.025 s 3 KBi
#5
Incorrecto
0.028 s 3 KBi
#6
Tiempo límite excedido
1.005 s 35 KBi
#7
Tiempo límite excedido
0.905 s 10 KBi
#8
Tiempo límite excedido
1.051 s 41 KBi
#9
Tiempo límite excedido
0.876 s 9 KBi
#10
Tiempo límite excedido
1.015 s 38 KBi
Puntos totales: 30 / 100

Código

def visualizer(buildings, heights):
    """Determines whether or not a given building can see the horizon

    Args:
        buildings (int): amount of buildings
        heights (list): list of heigths for each building

    Returns:
        list: A list containing -1 it the building is capable of seeing the
        horizon or the height of the blocking building
    """
    answers, highest = [], 0
    for i in range(buildings - 1, -1, -1):
        currentHeight = int(heights[i])
        if currentHeight >= highest:
            highest = currentHeight
            idx = i
            answers.insert(0, -1)
        else:
            ret = highest
            for j in range(i + 1, idx):
                if currentHeight < int(heights[j]):
                    ret = int(heights[j])
                    break
            answers.insert(0, ret)
    return answers
All = []
Repeats = int(input())
for i in range(0, Repeats):
    buildings = int(input())
    heights = input().split()
    All.append(visualizer(buildings, heights))

i = 1
for answer in All:
    print('Case #' + str(i), end=': ')
    print(*answer)