結果

問題 No.1077 Noelちゃんと星々4
ユーザー NoneNone
提出日時 2021-02-25 23:51:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 202 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 76,572 KB
最終ジャッジ日時 2024-04-09 03:02:49
合計ジャッジ時間 3,223 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,576 KB
testcase_01 AC 37 ms
53,480 KB
testcase_02 AC 129 ms
76,572 KB
testcase_03 AC 141 ms
76,156 KB
testcase_04 AC 81 ms
75,924 KB
testcase_05 AC 75 ms
75,328 KB
testcase_06 AC 91 ms
75,900 KB
testcase_07 AC 109 ms
75,800 KB
testcase_08 AC 85 ms
75,688 KB
testcase_09 AC 81 ms
75,740 KB
testcase_10 AC 141 ms
76,396 KB
testcase_11 AC 110 ms
76,252 KB
testcase_12 AC 101 ms
75,892 KB
testcase_13 AC 77 ms
75,388 KB
testcase_14 AC 146 ms
76,364 KB
testcase_15 AC 98 ms
76,288 KB
testcase_16 AC 81 ms
75,764 KB
testcase_17 AC 102 ms
76,200 KB
testcase_18 AC 141 ms
76,024 KB
testcase_19 AC 75 ms
75,432 KB
testcase_20 AC 39 ms
58,560 KB
testcase_21 AC 146 ms
76,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
Y=list(map(int, input().split()))
dp=[0]*(max(Y)+1)
for i in range(N):
    m=float("inf")
    for l in range(max(Y)+1):
        m=min(dp[l],m)
        dp[l]=m+abs(Y[i]-l)

print(min(dp))
0