結果

問題 No.4 おもりと天秤
ユーザー zazaboon
提出日時 2017-02-03 16:57:18
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 331 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-12-24 04:19:05
合計ジャッジ時間 2,951 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

# Here your code !
n=gets.chomp.to_i
a=gets.chomp.split(" ").map(&:to_i)
s = 0
t = 0
a.sort!.reverse!
a.each do |d|
    if(s > t)
        t += d
    else
        s += d
    end
end
if(s == t)
    puts "possible"
elsif(((s - t) % 2) == 1)
    puts "impossible"
else
    puts (a.include?((s-t).abs/2))? "possible" : "impossible"
end
0