結果

問題 No.2811 Calculation Within Sequence
ユーザー Lisp_CoderLisp_Coder
提出日時 2024-07-19 22:36:18
言語 Common Lisp
(sbcl 2.5.0)
結果
WA  
実行時間 -
コード長 1,209 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 46,592 KB
最終ジャッジ日時 2024-07-19 22:36:28
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other TLE * 1 -- * 40
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 19 JUL 2024 10:36:23 PM):

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

ソースコード

diff #

#-swank
(unless (member :child-sbcl *features*)
  (quit
   :recklessly-p t
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "1024MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defun parse-input ()
  (let* ((a (read))
         (b (read))
         (seq-T (make-array a :initial-element 0))
         (seq-S (make-array b :initial-element 0)))
    (dotimes (i a) (setf (aref seq-T i) (read)))
    (dotimes (i b) (setf (aref seq-S i) (read)))
    (values seq-T seq-S)))

(defun subset-sum (set target)
  (cond
    ((zerop target) t)
    ((null set) nil)
    (t (or (subset-sum (cdr set) target)
           (subset-sum (cdr set) (- target (car set)))))))

(defun can-make-equal (seq-T seq-S)
  (if (every #'(lambda (s) (subset-sum (coerce seq-T 'list) s)) seq-S)
      (format t "Yes~%")
      (format t "No~%")))

(defun main ()
  (multiple-value-bind (seq-T seq-S) (parse-input)
    (can-make-equal seq-T seq-S)))

(main)
0