結果

問題 No.77 レンガのピラミッド
ユーザー titiatitia
提出日時 2022-01-04 03:59:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 342 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 76,176 KB
最終ジャッジ日時 2024-04-21 18:51:34
合計ジャッジ時間 2,855 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,656 KB
testcase_01 AC 38 ms
51,744 KB
testcase_02 AC 37 ms
52,832 KB
testcase_03 AC 37 ms
52,740 KB
testcase_04 AC 39 ms
52,888 KB
testcase_05 AC 38 ms
52,488 KB
testcase_06 AC 342 ms
75,092 KB
testcase_07 AC 38 ms
52,312 KB
testcase_08 AC 160 ms
76,152 KB
testcase_09 AC 53 ms
65,556 KB
testcase_10 AC 53 ms
65,028 KB
testcase_11 AC 55 ms
66,440 KB
testcase_12 AC 101 ms
76,176 KB
testcase_13 AC 108 ms
75,308 KB
testcase_14 AC 129 ms
75,604 KB
testcase_15 AC 53 ms
64,496 KB
testcase_16 AC 51 ms
62,640 KB
testcase_17 AC 46 ms
60,336 KB
testcase_18 AC 100 ms
75,688 KB
testcase_19 AC 41 ms
58,544 KB
testcase_20 AC 43 ms
60,192 KB
testcase_21 AC 71 ms
71,520 KB
testcase_22 AC 53 ms
64,020 KB
testcase_23 AC 69 ms
70,316 KB
testcase_24 AC 37 ms
53,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

LANS=1<<60

def calc(A,k):
    
    ANS=0
    X=[min(i+1,k-i) for i in range(k)]
    #print(X)

    while len(X)<N:
        X.append(0)

    while len(A)<len(X):
        A.append(0)

    for i in range(len(A)):
        while A[i]>X[i]:
            ANS+=1
            A[i]-=1
            for j in range(len(A)):
                if A[j]<X[j]:
                    A[j]+=1
                    break
    #print(ANS)
    if X==A:
        return ANS
    else:
        return 1<<60

for i in range(1,2*N+1,2):
    LANS=min(LANS,calc(A[:],i))

print(LANS)
            
0