結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2024-10-23 17:39:39 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 18 ms / 5,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 354 ms |
コンパイル使用メモリ | 37,936 KB |
実行使用メモリ | 30,116 KB |
最終ジャッジ日時 | 2024-10-23 17:39:42 |
合計ジャッジ時間 | 2,007 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 23 OCT 2024 05:39:39 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.021
ソースコード
(defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (ws (loop repeat n collect (read))) (s (reduce #'+ ws))) (when (oddp s) (format t "impossible~%") (return-from main)) (let* ((s/2 (floor (/ s 2))) (dp (make-array (1+ s/2) :initial-element 0))) (setf (aref dp 0) 1) (loop for w in ws do (loop for i downfrom s/2 to 0 do (when (<= (+ i w) s/2) (setf (aref dp (+ i w)) (logior (aref dp (+ i w)) (aref dp i)))))) (format t "~a~%" (if (zerop (aref dp s/2)) "impossible" "possible"))))) (main)