結果

問題 No.1077 Noelちゃんと星々4
ユーザー SalmonizeSalmonize
提出日時 2020-06-12 21:27:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 559 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 9,092 KB
最終ジャッジ日時 2023-09-06 09:46:00
合計ジャッジ時間 29,406 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
8,812 KB
testcase_01 AC 46 ms
8,804 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 AC 784 ms
8,876 KB
testcase_05 AC 583 ms
8,908 KB
testcase_06 AC 1,007 ms
8,940 KB
testcase_07 AC 1,157 ms
8,872 KB
testcase_08 AC 843 ms
8,896 KB
testcase_09 AC 730 ms
8,992 KB
testcase_10 TLE -
testcase_11 AC 1,661 ms
8,944 KB
testcase_12 AC 1,373 ms
8,884 KB
testcase_13 AC 559 ms
8,904 KB
testcase_14 TLE -
testcase_15 AC 1,324 ms
8,936 KB
testcase_16 AC 872 ms
8,856 KB
testcase_17 AC 1,513 ms
8,944 KB
testcase_18 TLE -
testcase_19 AC 535 ms
8,896 KB
testcase_20 AC 19 ms
8,516 KB
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    m = 10**4 + 1
    l = nl()
    prv = [0]*m
    nxt = [0]*m
    for x in l:
        cur = prv[0]
        for i in range(m):
            cur = min(cur, prv[i])
            nxt[i] = abs(i - x) + cur
        prv, nxt = nxt, prv
    print(min(prv))
    return

solve()
0