結果

問題 No.77 レンガのピラミッド
ユーザー tnodinotnodino
提出日時 2022-03-08 18:08:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 580 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 75,968 KB
最終ジャッジ日時 2023-10-01 00:35:59
合計ジャッジ時間 4,897 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,804 KB
testcase_01 AC 83 ms
75,632 KB
testcase_02 AC 80 ms
75,748 KB
testcase_03 AC 79 ms
75,748 KB
testcase_04 AC 78 ms
75,396 KB
testcase_05 AC 77 ms
75,616 KB
testcase_06 AC 84 ms
75,728 KB
testcase_07 AC 78 ms
75,536 KB
testcase_08 AC 81 ms
75,568 KB
testcase_09 AC 81 ms
75,568 KB
testcase_10 AC 83 ms
75,856 KB
testcase_11 AC 82 ms
75,840 KB
testcase_12 AC 82 ms
75,476 KB
testcase_13 AC 81 ms
75,816 KB
testcase_14 AC 80 ms
75,968 KB
testcase_15 AC 82 ms
75,472 KB
testcase_16 AC 82 ms
75,452 KB
testcase_17 AC 79 ms
75,448 KB
testcase_18 AC 82 ms
75,568 KB
testcase_19 AC 78 ms
75,720 KB
testcase_20 AC 80 ms
75,428 KB
testcase_21 AC 82 ms
75,724 KB
testcase_22 AC 82 ms
75,780 KB
testcase_23 AC 80 ms
75,832 KB
testcase_24 AC 77 ms
75,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1<<32
M = 200
N = int(input())
A = list(map(int,input().split()))
ans = INF
for Len in range(1,M,2):
    P = [0] * M
    cnt = 1
    Mid = Len // 2
    for i in range(Len):
        P[i] = cnt
        if i < Mid:
            cnt += 1
        else:
            cnt -= 1
    Q = [0] * M
    for i in range(N):
        Q[i] = A[i]
    ret = 0
    cnt = 0
    for i in range(M):
        if P[i] < Q[i]:
            ret += Q[i] - P[i]
            cnt += Q[i] - P[i]
        else:
            cnt -= P[i] - Q[i]
    if cnt < 0:
        ret += INF
    ans = min(ans, ret)
print(ans)
0