結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2015-06-17 16:03:09 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 328 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 15,744 KB |
最終ジャッジ日時 | 2024-07-07 03:31:59 |
合計ジャッジ時間 | 8,481 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 TLE * 1 -- * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.chomp.to_i w = gets.chomp.split(' ').map {|i| i.to_i}.sort total = w.inject(:+) if total % 2 == 1 puts 'impossible' exit end (n-1).downto(n/2).each do |i| w.combination(i) do |set| sum = set.inject(:+) break if sum > total / 2 if total / 2 - sum == 0 puts 'possible' exit end end end puts 'impossible'