結果

問題 No.1077 Noelちゃんと星々4
ユーザー Eki1009Eki1009
提出日時 2020-06-12 21:54:56
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 426 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 233,648 KB
最終ジャッジ日時 2023-09-06 10:20:04
合計ジャッジ時間 7,641 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
76,924 KB
testcase_01 AC 90 ms
77,872 KB
testcase_02 AC 331 ms
184,492 KB
testcase_03 AC 397 ms
216,016 KB
testcase_04 AC 189 ms
118,832 KB
testcase_05 AC 159 ms
107,744 KB
testcase_06 AC 210 ms
131,324 KB
testcase_07 AC 232 ms
139,912 KB
testcase_08 AC 195 ms
122,728 KB
testcase_09 AC 177 ms
116,124 KB
testcase_10 AC 402 ms
216,408 KB
testcase_11 AC 289 ms
167,208 KB
testcase_12 AC 256 ms
151,260 KB
testcase_13 AC 159 ms
106,340 KB
testcase_14 AC 392 ms
213,092 KB
testcase_15 AC 250 ms
148,708 KB
testcase_16 AC 190 ms
123,784 KB
testcase_17 AC 269 ms
158,328 KB
testcase_18 AC 394 ms
218,956 KB
testcase_19 AC 154 ms
104,980 KB
testcase_20 AC 81 ms
76,096 KB
testcase_21 AC 426 ms
233,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
Y = tuple(map(int, input().split()))
U = 2*10**4
dp = [[0]*(U+1) for _ in range(n+1)]
for i, y in enumerate(Y):
    temp = float("inf")
    for j in range(U+1):
        k = j-10**4
        temp = min(temp, dp[i][j])
        dp[i+1][j] = temp + abs(y-k)
ans = min(dp[n])
print(ans)
0