(setf *l-stack* nil) (setf *n-stack* nil) (setf *index-list* nil) (defparameter *n* 7) (defparameter *v* '((1 1) (2 2) (9 3) (10 4) (1 5) (1 6) (4 7))) ;functions (defun separate-n (c) (cond ((char= c #\ ) (push (parse-integer (coerce (reverse *n-stack*) 'string)) *l-stack*) (setf *n-stack* '())) (t (push c *n-stack*))) ) (defun input-point (str) (map nil #'separate-n str) (push (parse-integer (coerce (reverse *n-stack*) 'string)) *l-stack*) (reverse *l-stack*) ) (defun make-v (points) (setf ret nil) (loop for item in points for i from 1 to 1000 do (push (list item i) ret)) (reverse ret) ) (defun sort-delicious (v) (sort v #'(lambda (x y) (> (car x) (car y)))) ) (defun neighbor_p (index l) (if (or (> (count (1+ index) l) 0) (> (count (1- index) l) 0)) t nil) ) (defun select (sorted n) (cond ((or (= n 0) (equal nil sorted)) nil) ((neighbor_p (cadr (car sorted)) *index-list*) (select (cdr sorted) n)) (t (push (cadr (car sorted)) *index-list*) (cons (car sorted) (select (cdr sorted) (1- n))) ) ) ) (defun calc (l-2d) (if (equal l-2d nil) 0 (+ (caar l-2d) (calc (cdr l-2d)))) ) (defun input () (setf *n* (parse-integer (read-line))) (setf *v* (make-v (input-point (read-line)))) ) (defun p-log () (print *n*) (print (ceiling *n* 2)) (print *v*) (print (sort-delicious *v*)) (print (select (sort-delicious *v*) (ceiling *n* 2))) (print *index-list*) ) (defun n45 () (input) ;(p-log) (princ (calc (select (sort-delicious *v*) (ceiling *n* 2)))) ) (n45)