結果

問題 No.1077 Noelちゃんと星々4
ユーザー しのしの
提出日時 2020-05-05 22:29:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 2,529 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 76,688 KB
最終ジャッジ日時 2023-09-09 13:03:14
合計ジャッジ時間 4,873 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,740 KB
testcase_01 AC 82 ms
75,900 KB
testcase_02 AC 161 ms
76,308 KB
testcase_03 AC 165 ms
76,108 KB
testcase_04 AC 111 ms
76,204 KB
testcase_05 AC 105 ms
76,260 KB
testcase_06 AC 119 ms
76,408 KB
testcase_07 AC 127 ms
76,276 KB
testcase_08 AC 114 ms
76,364 KB
testcase_09 AC 110 ms
76,412 KB
testcase_10 AC 165 ms
76,104 KB
testcase_11 AC 140 ms
76,104 KB
testcase_12 AC 129 ms
76,596 KB
testcase_13 AC 107 ms
75,932 KB
testcase_14 AC 161 ms
76,256 KB
testcase_15 AC 130 ms
76,188 KB
testcase_16 AC 117 ms
76,688 KB
testcase_17 AC 132 ms
76,392 KB
testcase_18 AC 165 ms
76,664 KB
testcase_19 AC 106 ms
76,084 KB
testcase_20 AC 83 ms
76,196 KB
testcase_21 AC 173 ms
76,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ys = map(int, input().split())

MaxY = 10005
dp = [0 for _ in range(MaxY)]

for y in ys:
  for j in range(MaxY):
    dp[j] += abs(j - y)
  for j in range(MaxY-1):
    dp[j+1] = min(dp[j], dp[j+1])

res = 10000007
for d in dp:
  res = min(res, d)

print(res)
0