結果

問題 No.77 レンガのピラミッド
ユーザー 👑 KazunKazun
提出日時 2021-02-07 18:49:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 400 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 75,884 KB
最終ジャッジ日時 2023-09-17 17:04:01
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,196 KB
testcase_01 AC 75 ms
70,772 KB
testcase_02 AC 76 ms
71,188 KB
testcase_03 AC 74 ms
71,092 KB
testcase_04 AC 75 ms
70,928 KB
testcase_05 AC 75 ms
71,204 KB
testcase_06 AC 86 ms
75,652 KB
testcase_07 AC 75 ms
71,072 KB
testcase_08 AC 84 ms
75,756 KB
testcase_09 AC 75 ms
71,092 KB
testcase_10 AC 75 ms
71,244 KB
testcase_11 AC 77 ms
75,384 KB
testcase_12 AC 81 ms
75,552 KB
testcase_13 AC 83 ms
75,816 KB
testcase_14 AC 82 ms
75,840 KB
testcase_15 AC 77 ms
70,960 KB
testcase_16 AC 77 ms
71,160 KB
testcase_17 AC 75 ms
71,164 KB
testcase_18 AC 82 ms
75,884 KB
testcase_19 AC 75 ms
71,160 KB
testcase_20 AC 75 ms
71,152 KB
testcase_21 AC 80 ms
75,788 KB
testcase_22 AC 74 ms
71,168 KB
testcase_23 AC 78 ms
75,504 KB
testcase_24 AC 75 ms
70,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A_sum=sum(A)
k=1
Ans=float("inf")
while k*k<=A_sum:
    B=list(range(1,k+1))
    B+=B[:-1][::-1]

    t=max(len(A),len(B))
    X=A+[0]*(t-len(A))
    Y=B+[0]*(t-len(B))

    p=q=0
    for i in range(len(A)):
        if X[i]<Y[i]:
            p+=Y[i]-X[i]
        else:
            q+=X[i]-Y[i]

    if q>=p:
        Ans=min(Ans,q)

    k+=1
print(Ans)
0