結果
| 問題 | No.527 ナップサック容量問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-11 01:55:30 |
| 言語 | Ruby (4.0.6 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 537 ms / 2,000 ms |
| + 709µs | |
| コード長 | 209 bytes |
| 記録 | |
| コンパイル時間 | 35 ms |
| コンパイル使用メモリ | 8,960 KB |
| 実行使用メモリ | 14,848 KB |
| 最終ジャッジ日時 | 2026-09-03 07:46:18 |
| 合計ジャッジ時間 | 9,295 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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