結果

問題 No.1077 Noelちゃんと星々4
ユーザー d9etd9et
提出日時 2020-06-12 21:35:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 155,384 KB
最終ジャッジ日時 2023-09-06 09:54:59
合計ジャッジ時間 5,071 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,208 KB
testcase_01 AC 70 ms
71,376 KB
testcase_02 AC 232 ms
130,896 KB
testcase_03 AC 256 ms
136,228 KB
testcase_04 AC 136 ms
91,332 KB
testcase_05 AC 127 ms
91,028 KB
testcase_06 AC 147 ms
91,060 KB
testcase_07 AC 172 ms
108,228 KB
testcase_08 AC 140 ms
91,336 KB
testcase_09 AC 133 ms
91,384 KB
testcase_10 AC 256 ms
136,368 KB
testcase_11 AC 195 ms
113,656 KB
testcase_12 AC 184 ms
113,480 KB
testcase_13 AC 127 ms
90,988 KB
testcase_14 AC 256 ms
136,320 KB
testcase_15 AC 179 ms
112,692 KB
testcase_16 AC 135 ms
91,372 KB
testcase_17 AC 184 ms
113,600 KB
testcase_18 AC 257 ms
136,076 KB
testcase_19 AC 125 ms
90,796 KB
testcase_20 AC 74 ms
76,300 KB
testcase_21 AC 287 ms
155,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
mx = max(a)
dp = [[10**18 for i in range(mx+1)] for j in range(n+1)]
dp[0][0] = 0
for i in range(1,n+1):
    x = a[i-1]
    mn = 10**18
    for j in range(mx+1):
        mn = min(mn,dp[i-1][j])
        dp[i][j] = mn+abs(x-j)
print(min(dp[-1]))
0