結果

問題 No.4 おもりと天秤
ユーザー zazaboonzazaboon
提出日時 2017-02-03 17:23:51
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 390 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 19,592 KB
最終ジャッジ日時 2023-08-25 18:26:51
合計ジャッジ時間 7,072 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,060 KB
testcase_01 AC 78 ms
15,168 KB
testcase_02 AC 81 ms
15,348 KB
testcase_03 AC 79 ms
15,156 KB
testcase_04 AC 79 ms
15,112 KB
testcase_05 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: `:' after local variable or literal is interpreted as binary operator
Main.rb:22: warning: even though it seems like symbol literal
Syntax OK

ソースコード

diff #

def zent(x,s)
    return if($f == 1)
    return if(s > $s)
    return if(x >= $n)
    if(s == $s)
        $f = 1; return;
    end
    zent(x+1,s)
    s += $a[x]
    zent(x+1,s)
end
$f = 0
$n=gets.chomp.to_i
$a=gets.chomp.split(" ").map(&:to_i).sort.reverse
$s = $a.inject(:+)
if ($s%2 == 1)
    puts "impossible"
    exit
end
$s = $s/2
zent(1,$a[0])
puts ($f == 1)? "possible" :"impossible"
0