結果

問題 No.2561 みんな大好きmod 998
ユーザー Common Lisp
提出日時 2024-11-05 23:26:15
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 553 ms / 4,000 ms
コード長 577 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 33,768 KB
実行使用メモリ 190,916 KB
最終ジャッジ日時 2024-11-05 23:26:25
合計ジャッジ時間 8,629 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 05 NOV 2024 11:26:15 PM):

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

ソースコード

diff #

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (k (read))
         (a (loop repeat n collect (read)))
         (dp (list (cons 0 0))))
    (dolist (b a)
      (let ((new-dp dp))
        (dolist (entry dp)
          (destructuring-bind (s . c) entry
            (when (< c k)
                (push (cons (+ s b) (1+ c)) new-dp)))
        (setf dp new-dp))))
    (let ((res (mod (count-if (lambda (entry) (destructuring-bind (s . cnt) entry (and (= cnt k) (<= (mod s 998244353) (mod s 998))))) dp) 998)))
      (format t "~d~%" res))))

(main)
0