結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-20 22:18:49 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 5,000 ms |
| コード長 | 386 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 76,300 KB |
| 実行使用メモリ | 77,584 KB |
| 最終ジャッジ日時 | 2024-09-17 12:22:19 |
| 合計ジャッジ時間 | 3,223 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
n = input()
a = map(int, raw_input().split())
total = sum(a)
h = 1
ans = float('inf')
while h * h <= total:
c = h - 1
low = 0
high = 0
for i in xrange(1000):
y = max(0, (i - c) + h if i <= c else -(i - c) + h)
if 0 <= i and i < n:
if a[i] < y:
low += y - a[i]
elif a[i] > y:
high += a[i] - y
else:
low += y
ans = min(ans, max(low, high))
h += 1
print ans