結果

問題 No.1077 Noelちゃんと星々4
ユーザー c-yanc-yan
提出日時 2020-06-14 10:33:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 272 ms / 2,000 ms
コード長 266 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 155,792 KB
最終ジャッジ日時 2023-09-09 08:51:10
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
76,028 KB
testcase_01 AC 74 ms
75,952 KB
testcase_02 AC 230 ms
131,156 KB
testcase_03 AC 266 ms
146,616 KB
testcase_04 AC 137 ms
98,196 KB
testcase_05 AC 120 ms
92,344 KB
testcase_06 AC 151 ms
104,120 KB
testcase_07 AC 183 ms
108,284 KB
testcase_08 AC 141 ms
99,708 KB
testcase_09 AC 135 ms
96,316 KB
testcase_10 AC 263 ms
146,548 KB
testcase_11 AC 196 ms
121,816 KB
testcase_12 AC 175 ms
114,416 KB
testcase_13 AC 124 ms
91,628 KB
testcase_14 AC 260 ms
145,068 KB
testcase_15 AC 177 ms
113,296 KB
testcase_16 AC 142 ms
100,240 KB
testcase_17 AC 182 ms
117,700 KB
testcase_18 AC 256 ms
148,208 KB
testcase_19 AC 117 ms
90,980 KB
testcase_20 AC 71 ms
76,020 KB
testcase_21 AC 272 ms
155,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int, input().split()))

dp = [[0] * (10 ** 4 + 1) for _ in range(N)]

for i in range(N):
    t = float('inf')
    for j in range(10 ** 4 + 1):
        t = min(t, dp[i - 1][j])
        dp[i][j] = t + abs(Y[i] - j)

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