結果

問題 No.4 おもりと天秤
ユーザー nakamura sosukenakamura sosuke
提出日時 2019-07-18 17:51:01
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 365 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 11,384 KB
実行使用メモリ 813,440 KB
最終ジャッジ日時 2023-08-26 20:30:05
合計ジャッジ時間 8,169 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
15,016 KB
testcase_01 AC 72 ms
15,088 KB
testcase_02 AC 80 ms
16,340 KB
testcase_03 AC 72 ms
15,204 KB
testcase_04 AC 76 ms
15,776 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
W = gets.split.map(&:to_i).sort!

sum = 0; W.each{ |w| sum += w }
if sum.odd?
  puts 'impossible'
  exit
end

half = sum / 2
candi = W.select{ |w| w <= half }
1.upto(N/2) do | cnt |
  candi.combination(cnt).to_a.each do | ws |
    sum = 0; ws.each{ |w| sum += w }
    if sum == half
      puts 'possible'
      exit
    end
  end
end
puts 'impossible'
0