結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2018-09-18 16:10:10 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 79 ms / 5,000 ms |
コード長 | 796 bytes |
コンパイル時間 | 51 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 16,128 KB |
最終ジャッジ日時 | 2024-07-18 07:59:50 |
合計ジャッジ時間 | 1,800 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
(define n (string->number (read-line))) (define w (map string->number (string-split (read-line) " "))) (define dp (make-vector 11000 0)) (define (check n w a) (unless (zero? n) (letrec* ((s (+ a (car w))) (check-1 (lambda (i) (unless (negative? i) (begin (when (= (vector-ref dp i) 1) (vector-set! dp (+ i (car w)) 1)) (check-1 (- i 1))))))) (check-1 10000) (check (- n 1) (cdr w) s)))) (let1 sum (fold + 0 w) (print (cond ((= (modulo sum 2) 1) "impossible") (else (vector-set! dp 0 1) (check n w 0) (if (zero? (vector-ref dp (/ sum 2))) "impossible" "possible")))))