結果

問題 No.1077 Noelちゃんと星々4
ユーザー しのしの
提出日時 2020-05-05 22:21:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,720 KB
実行使用メモリ 30,128 KB
最終ジャッジ日時 2023-09-09 12:45:18
合計ジャッジ時間 6,693 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
30,096 KB
testcase_01 AC 127 ms
29,960 KB
testcase_02 AC 157 ms
30,080 KB
testcase_03 AC 167 ms
30,044 KB
testcase_04 AC 137 ms
29,968 KB
testcase_05 AC 136 ms
29,996 KB
testcase_06 AC 142 ms
29,980 KB
testcase_07 AC 145 ms
29,932 KB
testcase_08 AC 139 ms
29,860 KB
testcase_09 AC 137 ms
29,964 KB
testcase_10 AC 169 ms
29,936 KB
testcase_11 AC 154 ms
29,972 KB
testcase_12 AC 150 ms
29,876 KB
testcase_13 AC 136 ms
29,996 KB
testcase_14 AC 169 ms
30,056 KB
testcase_15 AC 148 ms
30,044 KB
testcase_16 AC 140 ms
30,012 KB
testcase_17 AC 152 ms
29,988 KB
testcase_18 AC 173 ms
30,128 KB
testcase_19 AC 135 ms
29,972 KB
testcase_20 AC 126 ms
30,044 KB
testcase_21 AC 173 ms
29,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

read = sys.stdin.buffer.read

n, *y = map(int, read().split())

MaxY = 10005
dp = np.zeros(MaxY, dtype=np.int32)
ix = np.arange(MaxY)

for i in range(n):
  dp += abs(ix - y[i])
  np.minimum.accumulate(dp, out=dp)

print(np.minimum.reduce(dp))
0