結果

問題 No.1077 Noelちゃんと星々4
ユーザー stnkienstnkien
提出日時 2020-06-13 02:17:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 76,536 KB
最終ジャッジ日時 2023-09-06 11:40:44
合計ジャッジ時間 3,884 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,496 KB
testcase_01 AC 71 ms
71,148 KB
testcase_02 AC 125 ms
76,136 KB
testcase_03 AC 149 ms
76,536 KB
testcase_04 AC 102 ms
76,400 KB
testcase_05 AC 97 ms
75,848 KB
testcase_06 AC 108 ms
76,376 KB
testcase_07 AC 104 ms
76,516 KB
testcase_08 AC 104 ms
76,212 KB
testcase_09 AC 102 ms
76,360 KB
testcase_10 AC 148 ms
76,396 KB
testcase_11 AC 125 ms
76,016 KB
testcase_12 AC 117 ms
76,480 KB
testcase_13 AC 98 ms
75,936 KB
testcase_14 AC 147 ms
76,208 KB
testcase_15 AC 116 ms
76,004 KB
testcase_16 AC 100 ms
76,392 KB
testcase_17 AC 120 ms
76,532 KB
testcase_18 AC 148 ms
76,472 KB
testcase_19 AC 97 ms
76,140 KB
testcase_20 AC 75 ms
75,816 KB
testcase_21 AC 156 ms
76,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

INF = 1 << 60
maxY = max(Y)
dp = [0]*(maxY+1)

for y in Y:
    minx = INF
    for j in range(maxY+1):
        x = dp[j] + abs(y-j)
        if x < minx:
            minx = x
        dp[j] = minx

print(dp[-1])
0