結果
問題 | No.4 おもりと天秤 |
ユーザー | siman |
提出日時 | 2016-03-21 22:15:01 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 127 ms / 5,000 ms |
コード長 | 430 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 11,552 KB |
実行使用メモリ | 33,308 KB |
最終ジャッジ日時 | 2023-09-08 16:36:58 |
合計ジャッジ時間 | 3,326 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
15,048 KB |
testcase_01 | AC | 80 ms
15,320 KB |
testcase_02 | AC | 80 ms
15,396 KB |
testcase_03 | AC | 79 ms
15,200 KB |
testcase_04 | AC | 80 ms
15,520 KB |
testcase_05 | AC | 114 ms
30,812 KB |
testcase_06 | AC | 77 ms
15,096 KB |
testcase_07 | AC | 114 ms
30,384 KB |
testcase_08 | AC | 79 ms
15,636 KB |
testcase_09 | AC | 78 ms
15,488 KB |
testcase_10 | AC | 127 ms
33,308 KB |
testcase_11 | AC | 77 ms
15,160 KB |
testcase_12 | AC | 78 ms
15,272 KB |
testcase_13 | AC | 78 ms
15,344 KB |
testcase_14 | AC | 77 ms
15,152 KB |
testcase_15 | AC | 78 ms
15,096 KB |
testcase_16 | AC | 77 ms
15,164 KB |
testcase_17 | AC | 80 ms
15,276 KB |
testcase_18 | AC | 95 ms
22,328 KB |
testcase_19 | AC | 110 ms
28,272 KB |
testcase_20 | AC | 107 ms
27,180 KB |
testcase_21 | AC | 106 ms
26,744 KB |
testcase_22 | AC | 110 ms
27,068 KB |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - n Syntax OK
ソースコード
class Yukicoder def initialize n = gets.chomp.to_i w = gets.chomp.split.map(&:to_i).sort sum = w.inject(:+) hash = Hash.new(false) w.each do |num| temp = hash.dup hash.each do |k,v| temp[k+num] = true end hash = temp.dup hash[num] = true end if sum.even? && hash[sum/2] puts "possible" else puts "impossible" end end end Yukicoder.new