結果

問題 No.1077 Noelちゃんと星々4
ユーザー c-yanc-yan
提出日時 2020-06-14 10:36:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 295 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,544 KB
実行使用メモリ 8,648 KB
最終ジャッジ日時 2023-09-09 08:56:56
合計ジャッジ時間 30,232 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
8,336 KB
testcase_01 AC 46 ms
8,304 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 791 ms
8,608 KB
testcase_05 AC 599 ms
8,304 KB
testcase_06 AC 1,031 ms
8,588 KB
testcase_07 AC 1,190 ms
8,628 KB
testcase_08 AC 864 ms
8,644 KB
testcase_09 AC 745 ms
8,284 KB
testcase_10 TLE -
testcase_11 AC 1,696 ms
8,628 KB
testcase_12 AC 1,398 ms
8,528 KB
testcase_13 AC 570 ms
8,192 KB
testcase_14 TLE -
testcase_15 AC 1,353 ms
8,532 KB
testcase_16 AC 887 ms
8,604 KB
testcase_17 AC 1,531 ms
8,580 KB
testcase_18 TLE -
testcase_19 AC 541 ms
8,228 KB
testcase_20 AC 19 ms
8,268 KB
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    Y = list(map(int, input().split()))
    
    dp = [0] * (10 ** 4 + 1)
    
    for i in range(N):
        t = float('inf')
        for j in range(10 ** 4 + 1):
            t = min(t, dp[j])
            dp[j] = t + abs(Y[i] - j)
    
    print(min(dp))
main()
0