結果
問題 | No.247 線形計画問題もどき |
ユーザー |
|
提出日時 | 2016-04-04 23:08:16 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 1,548 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 90,880 KB |
最終ジャッジ日時 | 2024-07-07 11:14:21 |
合計ジャッジ時間 | 12,251 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
コンパイルメッセージ
Main.rb:20: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
INF = 1000000c = gets.to_in = gets.to_ia = gets.split.map(&:to_i)dp = Array.new(n + 1)(n + 1).times{|i|dp[i] = Array.new(c + 1,INF)dp[i][0] = 0}1.upto(n){|i|1.upto(a[i - 1] - 1){|j|dp[i][j] = dp[i - 1][j]}a[i - 1].upto(c){|j|dp[i][j] = [dp[i - 1][j], dp[i][j - a[i - 1]] + 1].min}}if dp[n][c] == INFp -1elsep dp[n][c]end