結果

問題 No.1077 Noelちゃんと星々4
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-12 22:26:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 249 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 86,420 KB
実行使用メモリ 91,008 KB
最終ジャッジ日時 2023-09-06 10:43:20
合計ジャッジ時間 6,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,284 KB
testcase_01 AC 78 ms
76,108 KB
testcase_02 AC 256 ms
86,228 KB
testcase_03 AC 305 ms
89,264 KB
testcase_04 AC 146 ms
79,992 KB
testcase_05 AC 126 ms
79,036 KB
testcase_06 AC 166 ms
80,964 KB
testcase_07 AC 180 ms
81,776 KB
testcase_08 AC 145 ms
80,432 KB
testcase_09 AC 137 ms
79,768 KB
testcase_10 AC 332 ms
89,468 KB
testcase_11 AC 216 ms
84,728 KB
testcase_12 AC 183 ms
82,828 KB
testcase_13 AC 122 ms
78,676 KB
testcase_14 AC 287 ms
88,772 KB
testcase_15 AC 198 ms
82,644 KB
testcase_16 AC 152 ms
80,304 KB
testcase_17 AC 202 ms
84,024 KB
testcase_18 AC 295 ms
89,952 KB
testcase_19 AC 124 ms
78,944 KB
testcase_20 AC 70 ms
75,400 KB
testcase_21 AC 317 ms
91,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
U = 10 ** 4 + 10

dp = [i for i in range(U)]
for a in A:
    dp = list(accumulate(dp, func=min))
    dp = [x + abs(i - a) for i, x in enumerate(dp)]
print(min(dp))
0