結果

問題 No.50 おもちゃ箱
ユーザー Common LispCommon Lisp
提出日時 2024-11-12 23:17:57
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 1,116 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 39,560 KB
実行使用メモリ 30,140 KB
最終ジャッジ日時 2024-11-12 23:18:00
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
26,024 KB
testcase_01 AC 13 ms
30,140 KB
testcase_02 AC 14 ms
29,864 KB
testcase_03 AC 8 ms
25,900 KB
testcase_04 AC 8 ms
26,020 KB
testcase_05 AC 27 ms
26,152 KB
testcase_06 AC 10 ms
29,860 KB
testcase_07 AC 8 ms
25,764 KB
testcase_08 AC 9 ms
27,980 KB
testcase_09 AC 8 ms
26,020 KB
testcase_10 AC 9 ms
27,852 KB
testcase_11 AC 9 ms
27,980 KB
testcase_12 AC 8 ms
27,852 KB
testcase_13 AC 8 ms
26,024 KB
testcase_14 AC 8 ms
26,024 KB
testcase_15 AC 9 ms
26,156 KB
testcase_16 AC 8 ms
26,028 KB
testcase_17 AC 13 ms
30,140 KB
testcase_18 AC 9 ms
25,896 KB
testcase_19 AC 12 ms
26,152 KB
testcase_20 AC 8 ms
26,024 KB
testcase_21 AC 10 ms
27,936 KB
testcase_22 AC 11 ms
30,140 KB
testcase_23 AC 9 ms
30,008 KB
testcase_24 AC 9 ms
29,988 KB
testcase_25 AC 9 ms
27,980 KB
testcase_26 AC 9 ms
27,848 KB
testcase_27 AC 14 ms
25,896 KB
testcase_28 AC 17 ms
30,116 KB
testcase_29 AC 15 ms
26,024 KB
testcase_30 AC 12 ms
30,136 KB
testcase_31 AC 10 ms
26,020 KB
testcase_32 AC 11 ms
26,020 KB
testcase_33 AC 12 ms
28,108 KB
testcase_34 AC 17 ms
27,980 KB
testcase_35 AC 12 ms
26,152 KB
testcase_36 AC 11 ms
26,152 KB
testcase_37 AC 17 ms
26,280 KB
testcase_38 AC 10 ms
26,280 KB
testcase_39 AC 17 ms
27,976 KB
testcase_40 AC 14 ms
28,108 KB
testcase_41 AC 15 ms
26,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 12 NOV 2024 11:17:57 PM):

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

ソースコード

diff #

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((*read-default-float-format* 'double-float)
         (dp1 (make-array (ash 1 10) :initial-element nil))
         (dp2 (make-array (ash 1 10) :initial-element nil))
         (n (read))
         (a (make-array n :element-type 'integer)))
    (dotimes (i n) (setf (aref a i) (read)))
    (let* ((m (read))
           (b (make-array m :element-type 'integer)))
      (dotimes (i m) (setf (aref b i) (read)))
      (sort b #'>)
      (setf (aref dp1 0) t)
      (dotimes (i m)
        (dotimes (j (ash 1 n))
          (let ((c 0))
            (dotimes (k n)
              (unless (evenp (ash j (- k)))
                      (incf c (aref a k))))
            (unless (> c (aref b i))
                    (loop for k from (1- (ash 1 n)) downto 0 do (setf (aref dp2 (logior j k)) (or (aref dp2 (logior j k)) (aref dp1 k)))))))
        (loop for k from (1- (ash 1 n)) downto 0 do (setf (aref dp1 k) (aref dp2 k)))
        (when (aref dp1 (1- (ash 1 n)))
              (format t "~d~%" (1+ i))
              (return-from main)))
      (format t "-1~%"))))

(main)
0