結果

問題 No.1 道のショートカット
ユーザー Common Lisp
提出日時 2024-11-07 23:33:26
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 1,444 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 37,632 KB
実行使用メモリ 22,272 KB
最終ジャッジ日時 2024-11-07 23:33:28
合計ジャッジ時間 1,916 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 07 NOV 2024 11:33:26 PM):

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

ソースコード

diff #
プレゼンテーションモードにする

(defconstant +inf+ 9876543210)
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((n (read))
(c (read))
(v (read))
(ss (make-array v :element-type 'integer))
(tt (make-array v :element-type 'integer))
(yy (make-array v :element-type 'integer))
(mm (make-array v :element-type 'integer))
(dp (make-array (list n (1+ c)) :initial-element +inf+))
(graph (make-array n :element-type 'list :initial-element nil)))
(dotimes (i v) (setf (aref ss i) (1- (read))))
(dotimes (i v) (setf (aref tt i) (1- (read))))
(dotimes (i v) (setf (aref yy i) (read)))
(dotimes (i v) (setf (aref mm i) (read)))
(dotimes (i v) (push (list (aref tt i) (aref yy i) (aref mm i)) (aref graph (aref ss i))))
(setf (aref dp 0 c) 0)
(loop for i below (1- n) do
(loop for j to c do
(when (< (aref dp i j) +inf+)
(dolist (pqr (aref graph i))
(let ((p (first pqr))
(q (second pqr))
(r (third pqr)))
(when (>= (- j q) 0)
(setf (aref dp p (- j q)) (min (aref dp p (- j q)) (+ r (aref dp i j))))))))))
(let ((res (loop for i to c minimize (aref dp (1- n) i))))
(format t "~d~%" (if (< res +inf+)
res
-1)))))
(main)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0