(defvar L (read-line)) (setq L (parse-integer L)) (defvar N (read-line)) (setq N (parse-integer N)) (defvar W (read-line)) (setq W (read-from-string (concatenate 'string "(" W ")" ) ) ) (defvar newW) (setq newW '()) (loop for x in W do (setq neww (append newW (list x)))) (setq W newW) (setq W (sort W #'<)) (defvar SUM 0) (defvar ANS 0) (defvar x) (loop for x in W do (if (> (+ SUM x) L) (return) (progn (incf ANS) (setq SUM (+ SUM x)))) ) (format 't "~d~%" ANS)