結果
| 問題 |
No.595 登山
|
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-11-12 20:45:00 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 1,500 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 482 ms |
| コンパイル使用メモリ | 64,024 KB |
| 実行使用メモリ | 36,852 KB |
| 最終ジャッジ日時 | 2024-11-12 20:45:06 |
| 合計ジャッジ時間 | 4,973 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 12 NOV 2024 08:45:01 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.212
ソースコード
(defconstant +inf+ 987654321987654321)
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((*read-default-float-format* 'double-float)
(n (read))
(p (read))
(h (make-array n :element-type 'integer))
(dp1 (make-array n :element-type 'integer :initial-element +inf+))
(dp2 (make-array n :element-type 'integer :initial-element +inf+)))
(dotimes (i n) (setf (aref h i) (read)))
(setf (aref dp1 0) 0)
(loop for i from 1 below n do
(setf (aref dp1 i) (min (+ p (aref dp2 (1- i))) (+ (aref dp1 (1- i)) (min (max (- (aref h i) (aref h (1- i))) 0) p)))
(aref dp2 i) (min (+ p (aref dp1 (1- i))) (+ (aref dp2 (1- i)) (min (max (- (aref h (1- i)) (aref h i)) 0) p)))))
(format t "~d~%" (min (aref dp1 (1- n)) (aref dp2 (1- n))))))
(main)
Common Lisp