結果

問題 No.4 おもりと天秤
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-06-14 13:24:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 269 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 15,380 KB
最終ジャッジ日時 2023-09-08 16:45:19
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,104 KB
testcase_01 AC 82 ms
15,172 KB
testcase_02 AC 89 ms
15,380 KB
testcase_03 AC 88 ms
15,060 KB
testcase_04 AC 92 ms
15,144 KB
testcase_05 AC 151 ms
15,272 KB
testcase_06 AC 81 ms
15,128 KB
testcase_07 AC 151 ms
15,148 KB
testcase_08 AC 141 ms
15,284 KB
testcase_09 AC 143 ms
15,148 KB
testcase_10 AC 151 ms
15,064 KB
testcase_11 AC 84 ms
15,120 KB
testcase_12 AC 81 ms
15,156 KB
testcase_13 AC 81 ms
15,036 KB
testcase_14 AC 82 ms
15,276 KB
testcase_15 AC 80 ms
15,296 KB
testcase_16 AC 84 ms
15,320 KB
testcase_17 AC 84 ms
15,296 KB
testcase_18 AC 148 ms
15,164 KB
testcase_19 AC 151 ms
15,124 KB
testcase_20 AC 151 ms
15,288 KB
testcase_21 AC 151 ms
15,328 KB
testcase_22 AC 153 ms
15,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n=STDIN.gets.to_i
bs=STDIN.gets.split(" ")

dp=Array.new(10002,0)
dp[0]=1
sum=0
bs.each do |e|
	e1=e.to_i
	sum+=e1
	(10000-e1).downto(0) do |i|
		if dp[i]==1 then
			dp[i+e1]=1
		end
	end
end
if sum%2==0 && dp[sum/2]==1 then
	puts "possible"
else
	puts "impossible"
end
0