(defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (f (make-array (list n n) :element-type 'integer)) (s 0) (dp (make-array (ash 1 n) :element-type 'integer :initial-element -1))) (dotimes (i n) (dotimes (j n) (setf (aref f i j) (read)))) (setf (aref dp 0) 0) (dotimes (i (ash 1 n)) (when (>= (aref dp i) 0) (dotimes (j n) (when (zerop (logand i (ash 1 j))) (setq s j) (return))) (loop for j from (1+ s) below n when (zerop (logand i (ash 1 j))) do (setf (aref dp (logior i (ash 1 s) (ash 1 j))) (max (aref dp (logior i (ash 1 s) (ash 1 j))) (+ (aref dp i) (aref f s j))))))) (format t "~d~%" (aref dp (1- (ash 1 n)))))) (main)