結果

問題 No.1077 Noelちゃんと星々4
ユーザー H3PO4H3PO4
提出日時 2020-06-12 21:42:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 234 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 10,652 KB
実行使用メモリ 30,068 KB
最終ジャッジ日時 2023-09-06 10:01:23
合計ジャッジ時間 6,828 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
29,624 KB
testcase_01 AC 134 ms
29,712 KB
testcase_02 AC 163 ms
30,068 KB
testcase_03 AC 170 ms
30,032 KB
testcase_04 AC 141 ms
29,936 KB
testcase_05 AC 137 ms
29,960 KB
testcase_06 AC 144 ms
30,008 KB
testcase_07 AC 147 ms
29,964 KB
testcase_08 AC 142 ms
30,000 KB
testcase_09 AC 141 ms
30,008 KB
testcase_10 AC 172 ms
29,996 KB
testcase_11 AC 157 ms
29,916 KB
testcase_12 AC 152 ms
29,948 KB
testcase_13 AC 140 ms
30,024 KB
testcase_14 AC 172 ms
29,960 KB
testcase_15 AC 151 ms
29,940 KB
testcase_16 AC 146 ms
30,036 KB
testcase_17 AC 156 ms
30,020 KB
testcase_18 AC 173 ms
29,948 KB
testcase_19 AC 137 ms
30,036 KB
testcase_20 AC 131 ms
29,796 KB
testcase_21 AC 178 ms
30,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N = int(input())
Y = tuple(map(int, input().split()))
MAX = max(Y) + 1
dp = np.zeros(MAX, dtype=int)
for i in range(N):
    np.minimum.accumulate(dp, out=dp)
    dp += np.abs(Y[i] - np.arange(MAX))
print(dp.min())
0