結果

問題 No.4 おもりと天秤
ユーザー suppy193suppy193
提出日時 2015-06-17 16:03:09
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 328 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 18,764 KB
最終ジャッジ日時 2023-09-21 09:19:10
合計ジャッジ時間 8,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,084 KB
testcase_01 AC 81 ms
15,148 KB
testcase_02 AC 82 ms
15,532 KB
testcase_03 AC 81 ms
15,016 KB
testcase_04 AC 80 ms
15,072 KB
testcase_05 AC 80 ms
15,232 KB
testcase_06 AC 80 ms
15,128 KB
testcase_07 AC 89 ms
18,764 KB
testcase_08 AC 82 ms
15,044 KB
testcase_09 AC 82 ms
15,192 KB
testcase_10 AC 88 ms
18,444 KB
testcase_11 AC 81 ms
15,080 KB
testcase_12 AC 80 ms
15,148 KB
testcase_13 AC 80 ms
15,036 KB
testcase_14 AC 80 ms
14,980 KB
testcase_15 AC 80 ms
15,036 KB
testcase_16 AC 81 ms
15,196 KB
testcase_17 AC 81 ms
14,980 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i
w = gets.chomp.split(' ').map {|i| i.to_i}.sort
total = w.inject(:+)
if total % 2 == 1
	puts 'impossible'
	exit
end
(n-1).downto(n/2).each do |i|
	w.combination(i) do |set|
		sum = set.inject(:+)
		break if sum > total / 2
		if total / 2 - sum == 0
			puts 'possible'
			exit
		end
	end
end
puts 'impossible'
0