結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  wotsushi | 
| 提出日時 | 2016-12-24 08:34:27 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 298 bytes | 
| コンパイル時間 | 129 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 38,144 KB | 
| 最終ジャッジ日時 | 2024-12-14 17:16:23 | 
| 合計ジャッジ時間 | 3,940 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 3 | 
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i
W = gets.split.map(&:to_i)
s = W.inject(:+)
dp = Array.new(s / 2 + 1, false)
dp[0] = true
W.product([*0..(s / 2 + 1)]).each do |w, i|
  if i >= w
    dp[i] ||= dp[i - w]
  end
end
ans = if s % 2 == 0 and dp[s / 2]
        "possible"
      else
        "impossible"
      end
puts ans
            
            
            
        