結果

問題 No.77 レンガのピラミッド
ユーザー catuppercatupper
提出日時 2014-11-26 00:49:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 380 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 6,988 KB
実行使用メモリ 6,208 KB
最終ジャッジ日時 2023-09-01 22:06:16
合計ジャッジ時間 1,477 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
5,992 KB
testcase_01 AC 12 ms
5,952 KB
testcase_02 AC 11 ms
5,992 KB
testcase_03 AC 11 ms
5,948 KB
testcase_04 AC 11 ms
6,032 KB
testcase_05 AC 12 ms
6,136 KB
testcase_06 AC 11 ms
6,196 KB
testcase_07 AC 11 ms
6,132 KB
testcase_08 AC 12 ms
6,000 KB
testcase_09 AC 11 ms
5,972 KB
testcase_10 AC 11 ms
6,040 KB
testcase_11 AC 12 ms
6,128 KB
testcase_12 AC 11 ms
6,208 KB
testcase_13 AC 11 ms
6,112 KB
testcase_14 AC 11 ms
6,100 KB
testcase_15 AC 11 ms
5,968 KB
testcase_16 AC 11 ms
6,096 KB
testcase_17 AC 12 ms
5,948 KB
testcase_18 AC 11 ms
6,024 KB
testcase_19 AC 11 ms
5,948 KB
testcase_20 AC 11 ms
6,140 KB
testcase_21 AC 11 ms
6,020 KB
testcase_22 AC 11 ms
6,180 KB
testcase_23 AC 11 ms
6,092 KB
testcase_24 AC 11 ms
6,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

###################
###蟻本を読もう!###
###################


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


k = 1
while((k+1)**2 <= sum(a)):k+=1

a += [0] * (k*3)
extra = sum(a) - k*k
res = 0

for x in xrange(len(a)):
	if x < k:
		res += abs(a[x] - (x+1))
	elif x < k * 2-1:
		res += abs(a[x] - (k*2-1-x))
	else: res += a[x]

print (res + extra) / 2
0