結果

問題 No.390 最長の数列
ユーザー Common Lisp
提出日時 2024-11-08 21:02:47
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 165 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 1,249 ms
コンパイル使用メモリ 32,128 KB
実行使用メモリ 30,592 KB
最終ジャッジ日時 2024-11-08 21:02:51
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 08 NOV 2024 09:02:47 PM):

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

ソースコード

diff #

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (a (make-array n))
         (res 0))
    (dotimes (i n) (setf (aref a i) (read)))
    (sort a #'<)
    (let* ((b (aref a (1- n)))
           (dp (make-array (1+ b) :initial-element 0)))
      (dotimes (i n)
        (let ((c (aref a i)))
          (setf (aref dp c) (max 1 (aref dp c)))
          (loop for j from (* 2 c) to b by c do
                (setf (aref dp j) (max (aref dp j) (1+ (aref dp c)))))))
      (dotimes (i n)
        (setq res (max res (aref dp (aref a i))))))
    (format t "~d~%" res)))

(main)
0