結果
| 問題 | No.77 レンガのピラミッド |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-20 22:18:49 |
| 言語 | PyPy2 (7.3.20) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 5,000 ms |
| コード長 | 386 bytes |
| 記録 | |
| コンパイル時間 | 122 ms |
| コンパイル使用メモリ | 80,896 KB |
| 実行使用メモリ | 82,624 KB |
| 最終ジャッジ日時 | 2026-04-06 06:57:56 |
| 合計ジャッジ時間 | 2,516 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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