結果
| 問題 | No.286 Modulo Discount Store |
| コンテスト | |
| ユーザー |
Common Lisp
|
| 提出日時 | 2024-11-07 13:50:15 |
| 言語 | Common Lisp (sbcl 2.6.3) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 949 bytes |
| 記録 | |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 31,872 KB |
| 実行使用メモリ | 22,912 KB |
| 最終ジャッジ日時 | 2026-05-07 21:58:24 |
| 合計ジャッジ時間 | 2,271 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 07 MAY 2026 09:58:21 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.084
ソースコード
(defconstant +inf+ 987654321987654321)
(defun main (&rest argv)
(declare (ignorable argv))
(let* ((n (read))
(m (make-array n :element-type 'integer))
(2^n (ash 1 n))
(dp1 (make-array 2^n :initial-element +inf+))
(dp2 (make-array 2^n :initial-element -1)))
(setf (aref dp1 0) 0)
(setf (aref dp2 0) 0)
(dotimes (i n) (setf (aref m i) (read)))
(dotimes (i 2^n)
(dotimes (j n)
(when (zerop (logand i (ash 1 j)))
(let ((k (logior i (ash 1 j))))
(when (= -1 (aref dp2 k))
(setf (aref dp2 k) (+ (aref dp2 i) (aref m j))))
(setf (aref dp1 k) (min (aref dp1 k)
(+ (aref dp1 i)
(max 0 (- (aref m j)
(mod (aref dp2 i) 1000))))))))))
(format t "~d~%" (aref dp1 (1- 2^n)))))
(main)
Common Lisp