結果

問題 No.1077 Noelちゃんと星々4
ユーザー 👑 H20H20
提出日時 2021-12-27 10:33:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,732 KB
実行使用メモリ 77,408 KB
最終ジャッジ日時 2023-10-25 08:58:49
合計ジャッジ時間 3,858 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,352 KB
testcase_01 AC 40 ms
53,352 KB
testcase_02 AC 182 ms
76,992 KB
testcase_03 AC 204 ms
77,160 KB
testcase_04 AC 106 ms
76,420 KB
testcase_05 AC 95 ms
75,632 KB
testcase_06 AC 121 ms
76,568 KB
testcase_07 AC 128 ms
76,440 KB
testcase_08 AC 112 ms
76,396 KB
testcase_09 AC 103 ms
76,316 KB
testcase_10 AC 204 ms
77,256 KB
testcase_11 AC 155 ms
76,812 KB
testcase_12 AC 138 ms
76,576 KB
testcase_13 AC 94 ms
75,612 KB
testcase_14 AC 201 ms
77,152 KB
testcase_15 AC 137 ms
76,596 KB
testcase_16 AC 111 ms
76,188 KB
testcase_17 AC 144 ms
76,832 KB
testcase_18 AC 205 ms
77,180 KB
testcase_19 AC 92 ms
75,600 KB
testcase_20 AC 43 ms
59,744 KB
testcase_21 AC 222 ms
77,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
Y = list(map(int,input().split()))
my = max(Y)+1
DP = [0]*(my)
for y in Y:
    NDP1 = [0]*my
    for i in range(my):
        NDP1[i] = DP[i]+abs(y-i)
    NDP = [10**7]*my
    for i in range(my):
        NDP[i] = min(NDP[i-1],NDP1[i])
    DP = NDP
print(min(DP))
0