結果

問題 No.1077 Noelちゃんと星々4
ユーザー mirucamiruca
提出日時 2020-06-13 11:38:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 155,224 KB
最終ジャッジ日時 2023-09-07 05:06:44
合計ジャッジ時間 5,224 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,340 KB
testcase_01 AC 70 ms
71,256 KB
testcase_02 AC 228 ms
130,628 KB
testcase_03 AC 258 ms
138,324 KB
testcase_04 AC 136 ms
92,984 KB
testcase_05 AC 123 ms
91,960 KB
testcase_06 AC 144 ms
92,920 KB
testcase_07 AC 176 ms
108,144 KB
testcase_08 AC 137 ms
92,884 KB
testcase_09 AC 134 ms
92,856 KB
testcase_10 AC 257 ms
138,564 KB
testcase_11 AC 190 ms
115,484 KB
testcase_12 AC 175 ms
113,668 KB
testcase_13 AC 124 ms
91,644 KB
testcase_14 AC 252 ms
138,712 KB
testcase_15 AC 176 ms
112,788 KB
testcase_16 AC 135 ms
92,804 KB
testcase_17 AC 183 ms
115,780 KB
testcase_18 AC 257 ms
138,516 KB
testcase_19 AC 122 ms
90,980 KB
testcase_20 AC 74 ms
76,084 KB
testcase_21 AC 275 ms
155,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
Y = list(map(int, input().split()))

mx = max(Y)
INF = 10 ** 18
dp = [[INF] * (mx + 1) for _ in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    mn = 10 ** 18
    for j in range(mx + 1):
        mn = min(mn, dp[i - 1][j])
        dp[i][j] = mn + abs(Y[i - 1] - j)

print(min(dp[-1]))
0