結果

問題 No.1077 Noelちゃんと星々4
ユーザー roarisroaris
提出日時 2020-06-27 07:06:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 453 ms / 2,000 ms
コード長 347 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 160,084 KB
最終ジャッジ日時 2023-09-18 19:01:17
合計ジャッジ時間 7,110 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
76,404 KB
testcase_01 AC 91 ms
76,124 KB
testcase_02 AC 353 ms
133,284 KB
testcase_03 AC 430 ms
150,160 KB
testcase_04 AC 196 ms
98,684 KB
testcase_05 AC 170 ms
93,196 KB
testcase_06 AC 227 ms
105,676 KB
testcase_07 AC 255 ms
110,208 KB
testcase_08 AC 207 ms
100,968 KB
testcase_09 AC 189 ms
97,596 KB
testcase_10 AC 430 ms
150,036 KB
testcase_11 AC 311 ms
124,120 KB
testcase_12 AC 269 ms
116,016 KB
testcase_13 AC 165 ms
92,276 KB
testcase_14 AC 412 ms
148,360 KB
testcase_15 AC 266 ms
114,856 KB
testcase_16 AC 206 ms
101,548 KB
testcase_17 AC 286 ms
119,272 KB
testcase_18 AC 423 ms
151,876 KB
testcase_19 AC 161 ms
91,732 KB
testcase_20 AC 85 ms
76,292 KB
testcase_21 AC 453 ms
160,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
Y = list(map(int, input().split()))
dp = [[0]*(10**4+1) for _ in range(N+1)]

for i in range(N):
    acc = [10**18]
    
    for j in range(10**4+1):
        acc.append(min(acc[-1], dp[i][j]))
    
    for j in range(10**4+1):
        dp[i+1][j] = acc[j+1]+abs(Y[i]-j)
    
print(min(dp[N]))
0