結果

問題 No.77 レンガのピラミッド
ユーザー pekempeypekempey
提出日時 2015-12-20 22:05:43
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 429 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 77,128 KB
実行使用メモリ 79,588 KB
最終ジャッジ日時 2023-10-17 14:35:34
合計ジャッジ時間 6,560 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
78,420 KB
testcase_01 AC 76 ms
77,264 KB
testcase_02 AC 84 ms
78,336 KB
testcase_03 AC 76 ms
77,264 KB
testcase_04 AC 73 ms
76,148 KB
testcase_05 AC 73 ms
76,148 KB
testcase_06 WA -
testcase_07 AC 79 ms
77,368 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 89 ms
78,504 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 75 ms
77,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input()
a = map(int, raw_input().split())
total = sum(a)

h = 1
ans = float('inf')
while h * h <= total:
	w = h * 2 - 1
	for j in xrange(n):
		low = 0
		high = 0
		for i in xrange(-111, 111):
			y = max(0, (i - j) + h if i <= j else -(i - j) + h)
			if 0 <= i and i < n:
				if a[i] < y:
					low += y - a[i]
				elif a[i] > y:
					high += a[i] - y
			else:
				high += y
		ans = min(ans, max(low, high))
	h += 1

print ans
0