結果

問題 No.1077 Noelちゃんと星々4
ユーザー paruf4paruf4
提出日時 2020-06-13 13:25:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 254 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 155,036 KB
最終ジャッジ日時 2023-09-07 07:38:11
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,036 KB
testcase_01 AC 72 ms
71,236 KB
testcase_02 AC 248 ms
130,484 KB
testcase_03 AC 258 ms
138,284 KB
testcase_04 AC 136 ms
92,812 KB
testcase_05 AC 124 ms
91,740 KB
testcase_06 AC 144 ms
92,680 KB
testcase_07 AC 173 ms
107,572 KB
testcase_08 AC 136 ms
92,708 KB
testcase_09 AC 134 ms
92,700 KB
testcase_10 AC 255 ms
138,436 KB
testcase_11 AC 188 ms
115,484 KB
testcase_12 AC 176 ms
113,328 KB
testcase_13 AC 128 ms
91,360 KB
testcase_14 AC 250 ms
138,432 KB
testcase_15 AC 176 ms
112,676 KB
testcase_16 AC 137 ms
92,372 KB
testcase_17 AC 180 ms
115,608 KB
testcase_18 AC 250 ms
138,264 KB
testcase_19 AC 123 ms
90,760 KB
testcase_20 AC 74 ms
75,812 KB
testcase_21 AC 268 ms
155,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mx=max(y)
inf=10**18
dp=[[inf]*(mx+1) for i in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
  mn=10**18
  for j in range(mx+1):
    mn=min(mn,dp[i-1][j])
    dp[i][j]=mn+abs(y[i-1]-j)
print(min(dp[-1]))

0