본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 12352번 Hedgemony (Large)

by 현장 2023. 11. 16.

-Code

for t in range(int(input())):
    n = int(input())
    bush = list(map(int, input().split()))

    for i in range(1, n - 1):
        if bush[i] > (bush[i - 1] + bush[i + 1]) / 2:
            bush[i] = (bush[i - 1] + bush[i + 1]) / 2

    print(f"Case #{t + 1}: {bush[-2]:6f}")