結果

問題 No.77 レンガのピラミッド
ユーザー yomo3
提出日時 2020-03-10 17:49:01
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 434 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-15 23:30:58
合計ジャッジ時間 1,816 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
s = sum(A)

ans = 100*100+10
max_height = int(s**0.5)
max_bottom = 2* max_height - 1
for bottom in range(1, max_bottom+1, 2):
    plus = 0
    for i in range(max(N, bottom)):
        if i < bottom:
            h = bottom -i if i > bottom // 2 else i + 1
        else:
            h = 0
        if i < N and A[i] > h:
            plus += A[i] - h
    ans = min(ans, plus)
print(ans)
0