1. A – Buy a Pen
入力文字列と、:blueなどのキーワードシンボルで比較したかったのですが、うまくできず。
とりあえず、文字列比較で。
;; (min-pen-price 20 30 10 "Blue") ;=> 20
(defun min-pen-price (r g b color)
(cond
((string= color "Red") (min g b))
((string= color "Blue") (min r g))
((string= color "Green") (min r b))))
(defun main ()
(princ (min-pen-price (read) (read) (read) (read-line))))
#-swank(main)Code language: Lisp (lisp)

2. B – Exact Price
(defun print-yesno (c)
(declare (type boolean c))
(princ (if c "Yes" "No")))
(defun main ()
(let ((x (read)))
(print-yesno (and (> x 0)
(= 0 (mod x 100))))))
#-swank(main)Code language: Lisp (lisp)

3. C – Grid Walk
(defun make-grid (H W lines)
(let ((grid (make-array (list H W) :element-type 'character
:initial-element #\.)))
(loop for line in lines
for i below H
do (loop for ch across line
for j below W
do (setf (aref grid i j) ch))
finally (return grid))))
(defun next-pos (i j dir)
(case dir
(#\L (cons i (1- j)))
(#\R (cons i (1+ j)))
(#\U (cons (1- i) j))
(#\D (cons (1+ i) j))))
(defun move-commands (H W i j grid commands)
(loop for dir across commands
with ci = (1- i)
with cj = (1- j)
for next = (next-pos ci cj dir)
for ni = (car next)
for nj = (cdr next)
when (and (<= 0 ni (1- H))
(<= 0 nj (1- W))
(eql (aref grid ni nj) #\.))
do (setf ci ni
cj nj)
finally (return (cons ci cj))))
(defun main ()
(let* ((H (read))
(W (read))
(Si (read))
(Sj (read))
(grid (make-grid H W (loop repeat H collect (read-line))))
(commands (read-line))
(pos (move-commands H W Si Sj grid commands)))
(format t "~a ~a" (1+ (car pos)) (1+ (cdr pos)))))
#-swank(main)
Code language: Lisp (lisp)

4. D – Perfect
(defun perfect-participants (N M events)
(loop for (a b) in events
with memo = (make-array N :initial-element 0)
do (incf (aref memo (1- a)))
when (= M (aref memo (1- a)))
collect a))
;; (perfect-participants 3 2 '((1 1) (3 2) (2 1) (3 1) (1 2)))
;;=> (3 1)
(defun main ()
(let* ((N (read))
(M (read))
(K (read))
(events (loop repeat K
collect (list (read) (read)))))
(loop for p in (perfect-participants N M events)
do (princ p)
(princ #\space))))
#-swank(main)Code language: Lisp (lisp)

5. E – Keys
Code language: Lisp (lisp)
6. A
Code language: Lisp (lisp)