結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
_Clay____
|
| 提出日時 | 2018-09-18 16:18:44 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 75 ms / 5,000 ms |
| コード長 | 764 bytes |
| コンパイル時間 | 66 ms |
| コンパイル使用メモリ | 6,948 KB |
| 実行使用メモリ | 16,128 KB |
| 最終ジャッジ日時 | 2024-07-18 08:00:14 |
| 合計ジャッジ時間 | 1,741 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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)
(unless (zero? n)
(letrec
((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)))))
(let1 sum (fold + 0 w)
(print
(cond ((= (modulo sum 2) 1) "impossible")
(else
(vector-set! dp 0 1)
(check n w)
(if (zero? (vector-ref dp (/ sum 2))) "impossible" "possible")))))
_Clay____