結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2023-02-15 03:19:15 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 314 bytes |
| コンパイル時間 | 105 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-07-17 14:24:03 |
| 合計ジャッジ時間 | 3,302 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - m Syntax OK
ソースコード
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
horiesiniti