結果

問題 No.1077 Noelちゃんと星々4
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-06-12 22:07:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 312 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 155,352 KB
最終ジャッジ日時 2023-09-06 10:30:23
合計ジャッジ時間 5,546 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,160 KB
testcase_01 AC 76 ms
71,380 KB
testcase_02 AC 251 ms
130,928 KB
testcase_03 AC 283 ms
138,292 KB
testcase_04 AC 146 ms
92,936 KB
testcase_05 AC 135 ms
91,848 KB
testcase_06 AC 159 ms
92,996 KB
testcase_07 AC 179 ms
108,280 KB
testcase_08 AC 154 ms
92,984 KB
testcase_09 AC 148 ms
92,808 KB
testcase_10 AC 282 ms
138,396 KB
testcase_11 AC 221 ms
115,864 KB
testcase_12 AC 198 ms
113,996 KB
testcase_13 AC 135 ms
91,400 KB
testcase_14 AC 282 ms
138,616 KB
testcase_15 AC 198 ms
112,352 KB
testcase_16 AC 150 ms
92,980 KB
testcase_17 AC 205 ms
115,940 KB
testcase_18 AC 282 ms
138,680 KB
testcase_19 AC 133 ms
91,032 KB
testcase_20 AC 81 ms
76,044 KB
testcase_21 AC 312 ms
155,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, = map(int, input().split())
X = list(map(int, input().split()))
M = max(X)
dp = [[0]*(M+1) for _ in range(N+1)]
for i in range(1, N+1):
    mnr = 10**18
    for j in range(M+1):
        dp[i][j] = min(mnr, dp[i-1][j]+abs(j-X[i-1]))
        mnr = min(dp[i][j], mnr)
print(min(dp[-1]))
0