結果

問題 No.472 平均順位
ユーザー Common LispCommon Lisp
提出日時 2024-11-12 22:07:51
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 1,768 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 39,924 KB
実行使用メモリ 90,412 KB
最終ジャッジ日時 2024-11-12 22:08:05
合計ジャッジ時間 13,300 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 12 NOV 2024 10:07:51 PM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.033

ソースコード

diff #

(defconstant +inf+ 987654321987654321)

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((*read-default-float-format* 'double-float)
         (n (read))
         (p (read))
         (dp1 (make-array 15015 :element-type 'integer :initial-element +inf+)))
    (setf (aref dp1 0) 0)
    (dotimes (_ n)
      (let* ((a (read))
             (b (read))
             (c (read))
             (dp2 (make-array 15015 :element-type 'integer :initial-element +inf+)))
        (loop for j to (* 3 n) do
              (when (>= j 0)
                    (setf (aref dp2 j) (min (aref dp2 j) (+ a (aref dp1 j)))))
              (when (>= j 1)
                    (setf (aref dp2 j) (min (aref dp2 j) (+ b (aref dp1 (- j 1))))))
              (when (>= j 2)
                    (setf (aref dp2 j) (min (aref dp2 j) (+ c (aref dp1 (- j 2))))))
              (when (>= j 3)
                    (setf (aref dp2 j) (min (aref dp2 j) (+ 1 (aref dp1 (- j 3)))))))
        (replace dp1 dp2)))
    (format t "~f~%" (/ (float (aref dp1 p) 0d0) (float n 0d0)))))

(main)
0