結果

問題 No.1077 Noelちゃんと星々4
ユーザー neterukunneterukun
提出日時 2020-06-12 21:44:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 156,220 KB
最終ジャッジ日時 2023-09-06 10:06:01
合計ジャッジ時間 6,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,136 KB
testcase_01 AC 88 ms
75,884 KB
testcase_02 AC 278 ms
131,220 KB
testcase_03 AC 329 ms
147,148 KB
testcase_04 AC 163 ms
98,132 KB
testcase_05 AC 148 ms
92,464 KB
testcase_06 AC 186 ms
104,704 KB
testcase_07 AC 212 ms
108,752 KB
testcase_08 AC 173 ms
99,868 KB
testcase_09 AC 161 ms
96,792 KB
testcase_10 AC 330 ms
147,284 KB
testcase_11 AC 248 ms
122,112 KB
testcase_12 AC 219 ms
114,324 KB
testcase_13 AC 145 ms
91,468 KB
testcase_14 AC 323 ms
145,476 KB
testcase_15 AC 219 ms
113,428 KB
testcase_16 AC 172 ms
100,620 KB
testcase_17 AC 228 ms
117,940 KB
testcase_18 AC 331 ms
148,428 KB
testcase_19 AC 141 ms
90,940 KB
testcase_20 AC 85 ms
75,944 KB
testcase_21 AC 361 ms
156,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
y = list(map(int, input().split()))
INF = 10 ** 9

ans = 10 ** 18
dp = [[INF] * (10 ** 4 + 1) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    ru = [INF] * (10 ** 4 + 2)
    for height in range(10 ** 4 + 1):
        ru[height + 1] = min(ru[height], dp[i][height])
    for height in range(10 ** 4 + 1):  
        dp[i + 1][height] = ru[height + 1] + abs(height - y[i])

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