結果

問題 No.77 レンガのピラミッド
ユーザー yuki2006yuki2006
提出日時 2014-11-25 22:11:16
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 567 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 6,708 KB
実行使用メモリ 6,184 KB
最終ジャッジ日時 2023-08-31 01:13:04
合計ジャッジ時間 1,281 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,184 KB
testcase_01 AC 9 ms
5,924 KB
testcase_02 AC 9 ms
6,060 KB
testcase_03 AC 9 ms
6,172 KB
testcase_04 AC 11 ms
6,068 KB
testcase_05 AC 10 ms
5,960 KB
testcase_06 AC 13 ms
6,008 KB
testcase_07 AC 10 ms
6,124 KB
testcase_08 AC 12 ms
6,128 KB
testcase_09 AC 9 ms
6,032 KB
testcase_10 AC 10 ms
6,124 KB
testcase_11 AC 11 ms
5,932 KB
testcase_12 AC 10 ms
5,928 KB
testcase_13 AC 10 ms
6,160 KB
testcase_14 AC 11 ms
6,164 KB
testcase_15 AC 10 ms
5,928 KB
testcase_16 AC 9 ms
6,056 KB
testcase_17 AC 10 ms
6,032 KB
testcase_18 AC 10 ms
5,932 KB
testcase_19 AC 10 ms
6,072 KB
testcase_20 AC 9 ms
6,164 KB
testcase_21 AC 9 ms
5,924 KB
testcase_22 AC 12 ms
6,072 KB
testcase_23 AC 10 ms
6,064 KB
testcase_24 AC 10 ms
6,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
A = [0] * 10001
B = map(int, raw_input().split())

for i, v in enumerate(B):
    A[i] = v

total = sum(A)

c = 0
sub_total = 0
mn = total

while sub_total <= total:
    diff = 0

    for i in xrange(c):
        t = A[i] - (i + 1)
        if t > 0:
            diff += t

    for i in xrange(c, c * 2 - 1):
        t = A[i] - (2 * c - i - 1)
        if t > 0:
            diff += t

    for i in xrange(c * 2 - 1, N):
        diff += A[i]

    mn = min(diff, mn)

    c += 1
    sub_total += c + (c - 1)

print mn
0