結果

問題 No.1077 Noelちゃんと星々4
ユーザー kohei2019kohei2019
提出日時 2022-07-25 22:52:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,032 KB
実行使用メモリ 78,564 KB
最終ジャッジ日時 2023-09-22 09:31:07
合計ジャッジ時間 5,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
76,120 KB
testcase_01 AC 90 ms
75,788 KB
testcase_02 AC 189 ms
78,304 KB
testcase_03 AC 203 ms
78,000 KB
testcase_04 AC 131 ms
77,404 KB
testcase_05 AC 124 ms
76,940 KB
testcase_06 AC 142 ms
77,528 KB
testcase_07 AC 157 ms
77,476 KB
testcase_08 AC 134 ms
77,244 KB
testcase_09 AC 126 ms
77,128 KB
testcase_10 AC 205 ms
78,392 KB
testcase_11 AC 163 ms
77,912 KB
testcase_12 AC 152 ms
77,960 KB
testcase_13 AC 121 ms
76,640 KB
testcase_14 AC 200 ms
78,220 KB
testcase_15 AC 153 ms
78,048 KB
testcase_16 AC 137 ms
77,616 KB
testcase_17 AC 157 ms
78,268 KB
testcase_18 AC 200 ms
78,404 KB
testcase_19 AC 117 ms
77,112 KB
testcase_20 AC 87 ms
75,984 KB
testcase_21 AC 206 ms
78,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsY = list(map(int,input().split()))
dp = [0]*(10**4+1)
inf = float('INF')
for i in range(N):
    y = lsY[i]
    dp2 = [0]*(10**4+1)
    m = inf
    for j in range(10**4+1):
        m = min(m,dp[j])
        dp2[j] = m + abs(j-y)
    dp = dp2
print(min(dp))
0