結果

問題 No.527 ナップサック容量問題
ユーザー letrangerjpletrangerjp
提出日時 2017-06-11 01:53:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 201 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 16,592 KB
最終ジャッジ日時 2023-10-24 20:37:47
合計ジャッジ時間 11,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
16,108 KB
testcase_01 AC 83 ms
16,108 KB
testcase_02 AC 83 ms
16,108 KB
testcase_03 AC 85 ms
16,108 KB
testcase_04 WA -
testcase_05 AC 199 ms
16,368 KB
testcase_06 AC 659 ms
16,572 KB
testcase_07 AC 435 ms
16,480 KB
testcase_08 AC 163 ms
16,136 KB
testcase_09 AC 84 ms
16,104 KB
testcase_10 AC 631 ms
16,548 KB
testcase_11 AC 307 ms
16,368 KB
testcase_12 AC 214 ms
16,368 KB
testcase_13 AC 696 ms
16,584 KB
testcase_14 AC 171 ms
16,164 KB
testcase_15 AC 282 ms
16,368 KB
testcase_16 AC 83 ms
16,108 KB
testcase_17 AC 203 ms
16,368 KB
testcase_18 AC 247 ms
16,368 KB
testcase_19 AC 84 ms
16,104 KB
testcase_20 AC 159 ms
16,136 KB
testcase_21 AC 771 ms
16,580 KB
testcase_22 AC 448 ms
16,504 KB
testcase_23 AC 670 ms
16,536 KB
testcase_24 AC 111 ms
16,108 KB
testcase_25 AC 371 ms
16,452 KB
testcase_26 AC 315 ms
16,360 KB
testcase_27 AC 344 ms
16,448 KB
testcase_28 AC 297 ms
16,368 KB
testcase_29 AC 799 ms
16,592 KB
testcase_30 AC 83 ms
16,108 KB
testcase_31 AC 84 ms
16,108 KB
testcase_32 AC 84 ms
16,104 KB
testcase_33 AC 97 ms
16,108 KB
testcase_34 AC 82 ms
16,108 KB
testcase_35 AC 309 ms
16,368 KB
testcase_36 AC 82 ms
16,108 KB
testcase_37 AC 214 ms
16,368 KB
testcase_38 AC 268 ms
16,364 KB
testcase_39 AC 240 ms
16,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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:d.rindex(V)
0