結果

問題 No.77 レンガのピラミッド
ユーザー mlihua09mlihua09
提出日時 2020-09-17 02:25:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 401 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 86,460 KB
実行使用メモリ 75,624 KB
最終ジャッジ日時 2023-09-04 04:22:42
合計ジャッジ時間 3,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,100 KB
testcase_01 AC 76 ms
71,120 KB
testcase_02 AC 77 ms
71,052 KB
testcase_03 AC 80 ms
71,028 KB
testcase_04 AC 76 ms
70,984 KB
testcase_05 AC 78 ms
71,016 KB
testcase_06 AC 87 ms
75,220 KB
testcase_07 AC 79 ms
71,052 KB
testcase_08 AC 88 ms
75,160 KB
testcase_09 AC 81 ms
74,660 KB
testcase_10 AC 80 ms
74,652 KB
testcase_11 AC 80 ms
74,824 KB
testcase_12 AC 86 ms
75,128 KB
testcase_13 AC 87 ms
75,624 KB
testcase_14 AC 89 ms
75,264 KB
testcase_15 AC 83 ms
74,608 KB
testcase_16 AC 80 ms
71,052 KB
testcase_17 AC 80 ms
70,868 KB
testcase_18 AC 85 ms
75,196 KB
testcase_19 AC 79 ms
71,088 KB
testcase_20 AC 78 ms
71,056 KB
testcase_21 AC 83 ms
75,172 KB
testcase_22 AC 79 ms
74,632 KB
testcase_23 AC 82 ms
74,856 KB
testcase_24 AC 77 ms
71,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


N = int(input())

A = list(map(int, input().split())) + [0] * N

a = sum(A)

ans = a - 1
for i in range(1, N):
    if (i + 1) ** 2 > a:
        break
    
    ans = min(ans, sum([A[j] - j - 1 if A[j] > j else 0 for j in range(i)]) + sum([A[j] - 2 * i - 1 + j if A[j] > 2 * i - j else 0 for j in range(i, 2 * i + 1)]) + sum([A[j] for j in range(2 * i + 1, 2 * N)]))

    
print(ans)
        
        
0