結果

問題 No.1077 Noelちゃんと星々4
ユーザー brthyyjpbrthyyjp
提出日時 2020-06-12 21:39:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 79,324 KB
最終ジャッジ日時 2024-06-24 04:37:33
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline

import copy

def main():

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

    n = 10**4+1

    dp = [0]*n
    for i in range(N):
        temp = [0]*n
        cum = [10**18]*(n+1)
        for j in range(n):
            cum[j+1] = min(cum[j], dp[j])
        for j in range(n):
            temp[j] = cum[j+1]+abs(j-Y[i])
        dp = copy.copy(temp)
    print(min(dp))

if __name__ =='__main__':
    main()
0