結果

問題 No.914 Omiyage
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-02-15 03:19:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 314 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 11,356 KB
実行使用メモリ 15,300 KB
最終ジャッジ日時 2023-09-24 13:35:34
合計ジャッジ時間 4,855 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,228 KB
testcase_01 AC 84 ms
15,196 KB
testcase_02 AC 83 ms
15,164 KB
testcase_03 AC 85 ms
15,128 KB
testcase_04 AC 82 ms
15,048 KB
testcase_05 AC 83 ms
15,236 KB
testcase_06 AC 82 ms
15,248 KB
testcase_07 AC 82 ms
15,240 KB
testcase_08 AC 82 ms
15,280 KB
testcase_09 AC 84 ms
15,224 KB
testcase_10 AC 82 ms
15,044 KB
testcase_11 AC 83 ms
14,940 KB
testcase_12 AC 85 ms
15,300 KB
testcase_13 AC 84 ms
15,016 KB
testcase_14 AC 85 ms
15,236 KB
testcase_15 AC 83 ms
15,296 KB
testcase_16 AC 82 ms
15,200 KB
testcase_17 AC 84 ms
15,248 KB
testcase_18 AC 81 ms
15,236 KB
testcase_19 AC 80 ms
15,204 KB
testcase_20 AC 80 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

n,m,k=gets.split(" ").map{|e| e.to_i}
dp=Array.new(k+1,-1)
dp[0]=1
n.times{
	xs=gets.split(" ").map{|e| e.to_i}
	dp2=Array.new(k+1,-1)
	xs.each{|x|
		(k-x).downto(0){|j|
			next if dp[j]==-1
			dp2[j+x]=1
		}
	}
	dp=dp2.dup
}
ans=-1
0.upto(k){|i|
	ans=i if dp[i]==1
}
if ans==-1 then
	puts ans
else
	puts k-ans
end
0