結果

問題 No.1268 Fruit Rush 2
ユーザー Common Lisp
提出日時 2024-11-11 20:41:35
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 715 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 41,668 KB
実行使用メモリ 25,216 KB
最終ジャッジ日時 2024-11-11 20:41:41
合計ジャッジ時間 5,681 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 11 NOV 2024 08:41:35 PM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.065

ソースコード

diff #

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (a (make-array n :element-type 'integer))
         (dp (make-array (1+ n) :element-type 'integer :initial-element 0))
         (res n))
    (dotimes (i n) (setf (aref a i) (read)))
    (sort a #'<)
    (loop for i from n downto 0 do
          (when (and (< (+ i 1) n) (= (+ (aref a i) 2) (aref a (+ i 1)))) (setf (aref dp i) (1+ (aref dp (+ i 1)))))
          (when (and (< (+ i 2) n) (= (+ (aref a i) 2) (aref a (+ i 2)))) (setf (aref dp i) (1+ (aref dp (+ i 2))))))
    (loop for i below (1- n)
          when (= (1+ (aref a i)) (aref a (1+ i)))
            do (incf res (1+ (aref dp (1+ i)))))
    (format t "~d~%" res)))

(main)
0