結果
| 問題 |
No.527 ナップサック容量問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-11 01:55:30 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 900 ms / 2,000 ms |
| コード長 | 209 bytes |
| コンパイル時間 | 42 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2024-09-24 15:48:35 |
| 合計ジャッジ時間 | 12,852 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
Syntax OK
ソースコード
A=$<.map{|s|s.split.map &:to_i}
N=A.shift[0]
V=A.pop[0]
B,C=A.transpose
d=[]
N.times{|i|C.sum.downto(C[i]){|j|d[j]=[d[j]||0,B[i]+d[j-C[i]]||=0].max}}
p [1,d.index(V)].max
puts V==d[-1]?:inf:[1,d.rindex(V)].max