結果

問題 No.77 レンガのピラミッド
ユーザー pekempeypekempey
提出日時 2015-12-20 22:18:49
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 386 bytes
コンパイル時間 1,746 ms
コンパイル使用メモリ 77,348 KB
実行使用メモリ 78,352 KB
最終ジャッジ日時 2023-10-17 14:35:49
合計ジャッジ時間 3,422 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
77,296 KB
testcase_01 AC 75 ms
77,296 KB
testcase_02 AC 74 ms
77,296 KB
testcase_03 AC 73 ms
77,296 KB
testcase_04 AC 74 ms
77,296 KB
testcase_05 AC 72 ms
76,180 KB
testcase_06 AC 93 ms
78,352 KB
testcase_07 AC 75 ms
77,296 KB
testcase_08 AC 90 ms
78,340 KB
testcase_09 AC 83 ms
78,188 KB
testcase_10 AC 81 ms
78,176 KB
testcase_11 AC 84 ms
78,188 KB
testcase_12 AC 93 ms
78,336 KB
testcase_13 AC 91 ms
78,336 KB
testcase_14 AC 91 ms
78,340 KB
testcase_15 AC 82 ms
78,176 KB
testcase_16 AC 80 ms
78,172 KB
testcase_17 AC 76 ms
77,308 KB
testcase_18 AC 90 ms
78,340 KB
testcase_19 AC 76 ms
77,308 KB
testcase_20 AC 76 ms
77,308 KB
testcase_21 AC 88 ms
78,308 KB
testcase_22 AC 80 ms
78,176 KB
testcase_23 AC 87 ms
78,308 KB
testcase_24 AC 72 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:
	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
0