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

Envío 1455

Problema 0xcf - Mirando al horizonte

  • Autor: Serivt
  • Fecha: 2020-10-28 00:37:55 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.024 s 3 KBi
#2
Correcto
0.021 s 3 KBi
#3
Correcto
0.022 s 3 KBi
#4
Correcto
0.023 s 3 KBi
#5
Correcto
0.025 s 3 KBi
#6
Tiempo límite excedido
1.03 s 39 KBi
#7
Tiempo límite excedido
1.032 s 12 KBi
#8
Tiempo límite excedido
1.07 s 53 KBi
#9
Tiempo límite excedido
1.019 s 13 KBi
#10
Tiempo límite excedido
1.079 s 58 KBi
Puntos totales: 50 / 100

Código

from collections import deque

cases = int(input())

for c in range(0, cases):
    n = int(input())
    a = list(map(int, input().split(" ")))
    output = ""
    history = deque()
    for i in range(n - 1, -1, -1):
        max_a = None
        while history:
            last = history[0]
            if a[i] >= last:
                history.popleft()
            else:
                max_a = last
                break
        history.appendleft(a[i])
        output = f"{max_a or -1} {output}"
    print("Case #%d: %s" % (c + 1, output.rstrip()))