結果

問題 No.37 遊園地のアトラクション
ユーザー Common LispCommon Lisp
提出日時 2024-11-16 16:25:59
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 1,258 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 37,496 KB
実行使用メモリ 22,016 KB
最終ジャッジ日時 2024-11-16 16:26:05
合計ジャッジ時間 3,577 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 16 NOV 2024 04:26:01 PM):

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

ソースコード

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

(defun main (&rest argv)
(declare (ignorable argv))
(let* ((tm (read))
(n (read))
(c (make-array n))
(v (make-array n))
(dp (make-array (1+ tm) :element-type 'integer :initial-element -1))
(res 0))
(dotimes (i n) (setf (aref c i) (read)))
(dotimes (i n) (setf (aref v i) (read)))
(setf (aref dp 0) 0)
(dotimes (i n)
(loop for j from (1- tm) downto 0
unless (= -1 (aref dp j))
do (let ((point (aref v i))
(a 0)
(k 1))
(loop while (plusp point)
do (progn
(let ((now (+ j (* k (aref c i)))))
(when (<= now tm)
(incf a point)
(if (< (aref dp now) (+ (aref dp j) a))
(setf (aref dp now) (+ (aref dp j) a))
(return))))
(incf k)
(setf point (floor point 2)))))))
(loop for i from tm downto 0 do
(setq res (max res (aref dp i))))
(format t "~d~%" res)))
(main)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0