結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-11-10 21:49:11 |
| 言語 | Common Lisp (sbcl 2.5.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 1,205 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 30,080 KB |
| 実行使用メモリ | 22,016 KB |
| 最終ジャッジ日時 | 2024-11-10 21:49:13 |
| 合計ジャッジ時間 | 1,695 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 10 NOV 2024 09:49:11 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.018
ソースコード
(defconstant +inf+ 1000000000000000000)
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((n (read))
(v (read))
(k 1)
(c (make-array 101 :element-type 'integer :initial-element 0))
(dp (make-array 10001 :element-type 'integer))
(res +inf+))
(loop for i from 1 to n do
(setf (aref c i) (read)
(aref c i) (+ (aref c i) (aref c (- i 1)))))
(loop for i from 2 to n
when (> (* (aref c k) i) (* (aref c i) k))
do (setq k i))
(loop for i from 1 to 10000 do
(setf (aref dp i) +inf+)
(loop for j from 1 to n
when (and (>= i j) (> (aref dp i) (+ (aref dp (- i j)) (aref c j))))
do (setf (aref dp i) (+ (aref dp (- i j)) (aref c j)))))
(decf v n)
(when (<= v 0)
(setq res (aref c n)))
(loop for i to 10000
when (<= i v)
do (let* ((r (floor (+ v k -1 (- i)) k))
(w (+ (aref c n) (aref dp i) (* r (aref c k)))))
(when (> res w)
(setq res w))))
(format t "~d~%" res)))
(main)
Common Lisp