結果

問題 No.1077 Noelちゃんと星々4
ユーザー rlangevinrlangevin
提出日時 2023-02-03 12:41:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 337 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 79,848 KB
最終ジャッジ日時 2023-09-15 10:02:35
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,752 KB
testcase_01 AC 81 ms
75,756 KB
testcase_02 AC 206 ms
79,164 KB
testcase_03 AC 220 ms
79,252 KB
testcase_04 AC 127 ms
77,648 KB
testcase_05 AC 120 ms
77,152 KB
testcase_06 AC 143 ms
78,244 KB
testcase_07 AC 155 ms
78,192 KB
testcase_08 AC 133 ms
77,652 KB
testcase_09 AC 127 ms
77,568 KB
testcase_10 AC 221 ms
79,372 KB
testcase_11 AC 176 ms
78,440 KB
testcase_12 AC 157 ms
78,300 KB
testcase_13 AC 117 ms
76,872 KB
testcase_14 AC 218 ms
79,412 KB
testcase_15 AC 155 ms
78,352 KB
testcase_16 AC 133 ms
77,660 KB
testcase_17 AC 164 ms
78,388 KB
testcase_18 AC 221 ms
79,340 KB
testcase_19 AC 120 ms
76,836 KB
testcase_20 AC 80 ms
75,648 KB
testcase_21 AC 239 ms
79,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int, input().split()))
M = 10005
inf = 10 ** 18
pre = [0] * M
Acp = [0] * (M + 1)
for i in range(N):
    dp = [0] * M
    Ac = [inf] * (M + 1)
    for y in range(M):
        dp[y] = Acp[y + 1] + abs(y - Y[i])
        Ac[y + 1] = min(Ac[y], dp[y])
    dp, pre = pre, dp
    Acp, Ac = Ac, Acp

print(min(pre))
0