結果

問題 No.1077 Noelちゃんと星々4
ユーザー 👑 KazunKazun
提出日時 2020-06-12 23:46:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 285 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 152,476 KB
最終ジャッジ日時 2023-09-06 11:30:03
合計ジャッジ時間 5,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
76,208 KB
testcase_01 AC 91 ms
76,156 KB
testcase_02 AC 244 ms
129,560 KB
testcase_03 AC 278 ms
147,264 KB
testcase_04 AC 151 ms
98,388 KB
testcase_05 AC 127 ms
83,372 KB
testcase_06 AC 159 ms
104,868 KB
testcase_07 AC 180 ms
106,784 KB
testcase_08 AC 152 ms
100,352 KB
testcase_09 AC 148 ms
96,864 KB
testcase_10 AC 291 ms
147,352 KB
testcase_11 AC 214 ms
122,628 KB
testcase_12 AC 192 ms
106,780 KB
testcase_13 AC 126 ms
83,572 KB
testcase_14 AC 263 ms
145,432 KB
testcase_15 AC 182 ms
106,696 KB
testcase_16 AC 156 ms
100,684 KB
testcase_17 AC 194 ms
106,692 KB
testcase_18 AC 264 ms
148,480 KB
testcase_19 AC 123 ms
83,272 KB
testcase_20 AC 87 ms
76,340 KB
testcase_21 AC 282 ms
152,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import copy
F=10**10

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

for i in range(N):
    y=Y[i]
    m=F

    for j in range(10**4+1):
        m=min(m,D[i][j])
        D[i+1][j]=min(D[i+1][j],m+abs(y-j))

print(min(D[-1]))
0