(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)