結果

問題 No.4 おもりと天秤
コンテスト
ユーザー zazaboon
提出日時 2017-02-03 17:23:51
言語 Ruby
(4.0.2)
コンパイル:
ruby -w -c _filename_
実行:
ruby _filename_
結果
TLE  
実行時間 -
コード長 390 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 102 ms
コンパイル使用メモリ 9,088 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2026-05-30 00:02:14
合計ジャッジ時間 7,619 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #
raw source code

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