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

Envío 560

Problema 0xcf - Mirando al horizonte

  • Autor: d4vsanchez
  • Fecha: 2020-09-07 14:14:09 UTC (Hace más de 4 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.023 s 3 KBi
#2
Incorrecto
0.022 s 3 KBi
#3
Correcto
0.027 s 3 KBi
#4
Correcto
0.025 s 3 KBi
#5
Incorrecto
0.022 s 3 KBi
#6
Incorrecto
0.48 s 49 KBi
#7
Correcto
0.402 s 47 KBi
#8
Correcto
0.435 s 60 KBi
#9
Incorrecto
0.447 s 49 KBi
#10
Incorrecto
0.461 s 63 KBi
Puntos totales: 50 / 100

Código

def get_blocking_buildings(building_sizes):
    output = []
    blocking_buildings = []
    for building in building_sizes[::-1]:
        while blocking_buildings and building >= blocking_buildings[-1]:
            blocking_buildings.pop()
        output.append(-1 if not blocking_buildings else blocking_buildings[0])
        blocking_buildings.append(building)

    return reversed(output)

def main():
    building_sizes_cases = []
    cases = int(input())

    for case in range(cases):
        buildings = int(input())
        building_sizes = list(map(int, input().split()))
        assert len(building_sizes) == buildings
        building_sizes_cases.append(building_sizes)

    for index, building_sizes_case in enumerate(building_sizes_cases):
        output = [str(i) for i in get_blocking_buildings(building_sizes_case)]
        print("Case #{}: {}".format(index + 1, " ".join(output)))

if __name__ == "__main__":
    main()