結果

問題 No.77 レンガのピラミッド
コンテスト
ユーザー Meso Meso
提出日時 2025-10-27 11:12:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2025-10-27 11:12:49
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
a = list(map(int, input().split()))
sum_blocks = sum(a)
level = int(math.sqrt(sum_blocks))

total = float('inf')

for i in range(level - 1, level):
    t = 0
    for j in range(n):
        h = a[j] if 0 <= j < n else 0
        base = level - abs(i - j) if level >= abs(i - j) else 0
        if h > base:
            t += h - base
    total = min(total, t)

print(total)
0