結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
16,108 KB
testcase_01 AC 80 ms
16,108 KB
testcase_02 AC 78 ms
16,108 KB
testcase_03 AC 79 ms
16,108 KB
testcase_04 WA -
testcase_05 AC 194 ms
16,368 KB
testcase_06 AC 677 ms
16,572 KB
testcase_07 AC 427 ms
16,480 KB
testcase_08 AC 162 ms
16,136 KB
testcase_09 AC 79 ms
16,108 KB
testcase_10 AC 623 ms
16,548 KB
testcase_11 AC 299 ms
16,368 KB
testcase_12 AC 208 ms
16,368 KB
testcase_13 AC 689 ms
16,584 KB
testcase_14 AC 167 ms
16,164 KB
testcase_15 AC 277 ms
16,368 KB
testcase_16 AC 79 ms
16,108 KB
testcase_17 AC 199 ms
16,368 KB
testcase_18 AC 240 ms
16,368 KB
testcase_19 AC 82 ms
16,108 KB
testcase_20 AC 154 ms
16,136 KB
testcase_21 AC 763 ms
16,580 KB
testcase_22 AC 441 ms
16,504 KB
testcase_23 AC 662 ms
16,536 KB
testcase_24 AC 107 ms
16,108 KB
testcase_25 AC 363 ms
16,452 KB
testcase_26 AC 310 ms
16,368 KB
testcase_27 AC 339 ms
16,448 KB
testcase_28 AC 291 ms
16,368 KB
testcase_29 AC 794 ms
16,592 KB
testcase_30 AC 79 ms
16,108 KB
testcase_31 WA -
testcase_32 AC 80 ms
16,108 KB
testcase_33 AC 78 ms
16,104 KB
testcase_34 WA -
testcase_35 AC 305 ms
16,368 KB
testcase_36 AC 79 ms
16,108 KB
testcase_37 AC 207 ms
16,368 KB
testcase_38 AC 263 ms
16,368 KB
testcase_39 AC 239 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,a=d.index(V)].max
b=d.rindex V
puts a<b ?b: :inf
0