結果

問題 No.4 おもりと天秤
ユーザー code-devocode-devo
提出日時 2016-01-20 02:39:34
言語 Ruby
(3.2.2)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 326 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 11,456 KB
実行使用メモリ 20,976 KB
最終ジャッジ日時 2023-09-08 16:31:53
合計ジャッジ時間 3,306 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,184 KB
testcase_01 AC 78 ms
15,164 KB
testcase_02 AC 79 ms
15,256 KB
testcase_03 AC 79 ms
15,048 KB
testcase_04 AC 79 ms
15,112 KB
testcase_05 AC 119 ms
20,620 KB
testcase_06 AC 81 ms
15,240 KB
testcase_07 AC 113 ms
20,124 KB
testcase_08 AC 76 ms
15,092 KB
testcase_09 AC 79 ms
15,152 KB
testcase_10 AC 117 ms
20,976 KB
testcase_11 AC 77 ms
15,140 KB
testcase_12 AC 77 ms
15,344 KB
testcase_13 AC 78 ms
15,300 KB
testcase_14 AC 78 ms
15,144 KB
testcase_15 AC 78 ms
15,244 KB
testcase_16 AC 78 ms
15,144 KB
testcase_17 AC 79 ms
15,092 KB
testcase_18 AC 95 ms
17,564 KB
testcase_19 AC 108 ms
19,816 KB
testcase_20 AC 105 ms
19,464 KB
testcase_21 AC 103 ms
19,468 KB
testcase_22 AC 106 ms
19,540 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

gets
NS = gets.split.map(&:to_i).sort
SUM = NS.inject(&:+)
Q, R = SUM.divmod(2)
if R == 0 then
  h = {}
  h[0] = true

  while n = NS.shift do
    add = {}
    h.each do |k, v|
      next if k + n > Q
      add[k + n] = true
    end
    h.update add
  end

  puts h[Q] ? "possible" : "impossible"
else
  puts "impossible"
end
0