結果

問題 No.77 レンガのピラミッド
ユーザー tnodinotnodino
提出日時 2022-03-02 19:14:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 8,024 KB
最終ジャッジ日時 2023-09-23 10:57:41
合計ジャッジ時間 1,877 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,804 KB
testcase_01 AC 18 ms
7,752 KB
testcase_02 AC 17 ms
7,800 KB
testcase_03 AC 17 ms
7,800 KB
testcase_04 AC 16 ms
7,860 KB
testcase_05 AC 17 ms
7,868 KB
testcase_06 WA -
testcase_07 AC 16 ms
7,924 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,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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