結果

問題 No.45 回転寿司
ユーザー Common Lisp
提出日時 2024-10-28 04:51:21
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 500 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 35,648 KB
実行使用メモリ 30,012 KB
最終ジャッジ日時 2024-10-28 04:51:23
合計ジャッジ時間 2,118 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 28 OCT 2024 04:51:21 AM):

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

ソースコード

diff #

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (v (make-array n))
         (dp (make-array (1+ n) :initial-element (cons 0 0))))
    (dotimes (i n)
      (setf (aref v i) (read)))
    (loop for i from 1 to n do
          (setf (aref dp i) (cons (max (car (aref dp (1- i))) (cdr (aref dp (1- i))))
                                  (+ (car (aref dp (1- i))) (aref v (1- i)))))
          finally (format t "~D~%" (max (car (aref dp n)) (cdr (aref dp n)))))))

(main)
0