結果

問題 No.77 レンガのピラミッド
ユーザー nanaenanae
提出日時 2017-03-23 07:01:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 8,016 KB
最終ジャッジ日時 2023-09-19 08:33:13
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,752 KB
testcase_01 AC 16 ms
7,748 KB
testcase_02 AC 16 ms
7,760 KB
testcase_03 AC 17 ms
7,792 KB
testcase_04 AC 16 ms
7,920 KB
testcase_05 AC 16 ms
7,848 KB
testcase_06 WA -
testcase_07 AC 17 ms
7,828 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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 16 ms
7,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def calc_nb(h):
    return h**2

N = int(input())
A = [int(i) for i in input().split()]
num_b = sum(A)

btm = 0
top = 1000

while top - btm > 1:
    mid = (top + btm) // 2

    if num_b >= calc_nb(mid):
        btm = mid
    else:
        top = mid

h = min((N + 1) // 2, btm)
trash = num_b - calc_nb(h)
ans = trash

for i in range(h - 1):
    ans += max(0, (i + 1) - A[i])

for i in range(h - 1):
    ans += max(0, (i + 1) - A[2*h - 2 - i])

ans += max(0, h - A[h - 1])

print(ans)
0