結果

問題 No.1077 Noelちゃんと星々4
ユーザー brthyyjpbrthyyjp
提出日時 2020-06-12 21:39:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 81,248 KB
最終ジャッジ日時 2023-09-06 09:58:18
合計ジャッジ時間 5,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
76,188 KB
testcase_01 AC 94 ms
76,244 KB
testcase_02 AC 219 ms
80,388 KB
testcase_03 AC 255 ms
79,892 KB
testcase_04 AC 149 ms
78,544 KB
testcase_05 AC 129 ms
77,264 KB
testcase_06 AC 160 ms
78,876 KB
testcase_07 AC 164 ms
79,444 KB
testcase_08 AC 149 ms
78,448 KB
testcase_09 AC 143 ms
78,620 KB
testcase_10 AC 252 ms
79,796 KB
testcase_11 AC 198 ms
79,768 KB
testcase_12 AC 177 ms
79,188 KB
testcase_13 AC 130 ms
77,224 KB
testcase_14 AC 251 ms
79,828 KB
testcase_15 AC 180 ms
79,172 KB
testcase_16 AC 153 ms
78,884 KB
testcase_17 AC 195 ms
79,780 KB
testcase_18 AC 259 ms
79,712 KB
testcase_19 AC 131 ms
77,352 KB
testcase_20 AC 94 ms
76,328 KB
testcase_21 AC 271 ms
81,248 KB
権限があれば一括ダウンロードができます

ソースコード

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