結果

問題 No.77 レンガのピラミッド
ユーザー mlihua09mlihua09
提出日時 2020-09-17 02:02:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 764 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2023-09-04 04:22:38
合計ジャッジ時間 3,545 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,092 KB
testcase_01 AC 73 ms
71,260 KB
testcase_02 AC 73 ms
71,384 KB
testcase_03 AC 72 ms
71,376 KB
testcase_04 AC 71 ms
71,636 KB
testcase_05 AC 72 ms
71,432 KB
testcase_06 WA -
testcase_07 AC 71 ms
71,420 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 75 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


N = int(input())

A = list(map(int, input().split()))

ans = 10 ** 9

for i in range((N + 1) // 2):
    
    for j in range(N - 2 * i):
        x = sum(A[:j]) + sum(A[j + 2 * i + 1:])
        y = 0
        for k in range(i):
            
            if A[k + j] > k:
                
                x += A[k + j] - k - 1
                
            else:
                y += j + 1 - A[k + j]
                
        for k in range(i + 1):
            
            if A[j + i + k] > (i + 1) - k:
                
                x += A[j + i + k] - i - 1 + k
                
            else:
                
                y += i + 1 - k - A[j + i + k]
                
        if x >= y:
            
            ans = min(ans, x)
            
print(ans)
0