結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
76,204 KB
testcase_01 AC 79 ms
75,976 KB
testcase_02 AC 244 ms
130,532 KB
testcase_03 AC 259 ms
138,828 KB
testcase_04 AC 135 ms
93,148 KB
testcase_05 AC 127 ms
92,172 KB
testcase_06 AC 147 ms
92,528 KB
testcase_07 AC 162 ms
108,404 KB
testcase_08 AC 136 ms
92,788 KB
testcase_09 AC 134 ms
92,880 KB
testcase_10 AC 273 ms
138,764 KB
testcase_11 AC 198 ms
115,788 KB
testcase_12 AC 186 ms
114,268 KB
testcase_13 AC 120 ms
91,744 KB
testcase_14 AC 267 ms
138,780 KB
testcase_15 AC 185 ms
112,812 KB
testcase_16 AC 141 ms
93,000 KB
testcase_17 AC 198 ms
115,652 KB
testcase_18 AC 276 ms
138,752 KB
testcase_19 AC 129 ms
91,076 KB
testcase_20 AC 81 ms
76,044 KB
testcase_21 AC 300 ms
155,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [[0] * (10**4+1) for _ in range(1+n)]
# dp[0][0] = 0

for i in range(1,n+1):
    for j in range(10**4+1):
        if(j==0):
            dp[i][j] = dp[i-1][j] + abs(j-y[i-1])
        else:
            dp[i][j] = min(dp[i][j-1], dp[i-1][j] + abs(j-y[i-1]))

print(min(dp[i]))
0