結果
問題 | No.4 おもりと天秤 |
ユーザー | MiyamonY |
提出日時 | 2019-09-05 12:14:04 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 804 bytes |
コンパイル時間 | 68 ms |
コンパイル使用メモリ | 5,296 KB |
実行使用メモリ | 41,296 KB |
最終ジャッジ日時 | 2023-09-01 22:08:07 |
合計ジャッジ時間 | 49,497 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 65 ms
18,388 KB |
testcase_01 | AC | 71 ms
19,144 KB |
testcase_02 | AC | 162 ms
22,936 KB |
testcase_03 | AC | 108 ms
20,148 KB |
testcase_04 | AC | 170 ms
22,928 KB |
testcase_05 | AC | 4,872 ms
41,240 KB |
testcase_06 | AC | 61 ms
18,096 KB |
testcase_07 | AC | 4,933 ms
41,228 KB |
testcase_08 | AC | 3,740 ms
41,020 KB |
testcase_09 | AC | 3,810 ms
41,296 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 88 ms
20,060 KB |
testcase_12 | AC | 64 ms
18,336 KB |
testcase_13 | AC | 64 ms
18,268 KB |
testcase_14 | AC | 66 ms
18,720 KB |
testcase_15 | AC | 63 ms
18,332 KB |
testcase_16 | AC | 93 ms
20,084 KB |
testcase_17 | AC | 85 ms
20,056 KB |
testcase_18 | AC | 4,308 ms
41,292 KB |
testcase_19 | AC | 4,796 ms
41,240 KB |
testcase_20 | AC | 4,781 ms
41,184 KB |
testcase_21 | AC | 4,714 ms
41,164 KB |
testcase_22 | AC | 4,777 ms
41,204 KB |
ソースコード
(use gauche.array) (let* ((n (string->number (read-line))) (weights (map string->number (string-split (read-line) #\space))) (total (fold + 0 weights)) (max-weight 100) (arr (make-array (shape 0 (+ n 1) 0 (+ (* max-weight n) 1)) #f))) (array-set! arr 0 0 #t) (let loop ((weights weights) (i 1)) (cond ((null? weights) (if (or (= (mod total 2) 1) (eqv? (array-ref arr n (div total 2)) #f)) (print "impossible") (print "possible"))) (else (for-each (lambda (j) (let1 pred (- j (car weights)) (if (and (>= pred 0) (array-ref arr (- i 1) pred)) (array-set! arr i j #t))) (if (array-ref arr (- i 1) j) (array-set! arr i j #t))) (iota (+ (* max-weight n) 1))) (loop (cdr weights) (+ i 1))))))