; 6個以上の配列を用意してカウントしていく ; メモした配列の中から最大のものうちインデックスが最大のものを答える (defun main () (let* ((n (read)) (memo (make-array 7 :initial-element 0))) (dotimes (_ n) (let ((m (read))) (incf (aref memo m)))) ; reduce function sequence &key key from-end start end initial-value ⇒ result ; reduce 関数は sequence の要素を(デフォルトでは)左から function を ; start から end まで順次適用していく (let ((l (reduce #'max memo))) ; position item sequence &key from-end test test-not start end key => position ; from-end t によって難易度が高い順に最大値を調べることができる (princ (position l memo :from-end t)) (terpri)))) (main) ; (defun another-main () ; (let* ((n (read)) ; (xs (make-array 6 :initial-element 0)) ; (ans 1) ; (v 0)) ; (dotimes (_ n) ; (incf (aref xs (1- (read))))) ; (dotimes (i 6) ; (if (>= (aref xs i) v) ; (progn ; (setq ans (1+ i)) ; (setq v (aref xs i))))) ; (princ ans) ; (terpri)))