結果
| 問題 | No.595 登山 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-21 14:14:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 600 ms / 1,500 ms |
| コード長 | 482 bytes |
| 記録 | |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 29,548 KB |
| 最終ジャッジ日時 | 2024-12-21 16:23:50 |
| 合計ジャッジ時間 | 12,941 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
ソースコード
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, P, *H = map(int, read().split())
# 最後の 2 地点間ごとの値。jump, right, left
INF = 10 ** 18
dp = [INF, 0, INF]
for h1, h2 in zip(H, H[1:]):
newdp = [INF, INF, INF]
newdp[0] = min(dp) + P
newdp[1] = min(dp[0], dp[1]) + max(0, h2 - h1)
newdp[2] = min(dp[0], dp[2]) + max(0, h1 - h2)
dp = newdp
print(min(dp))
maspy