結果

問題 No.527 ナップサック容量問題
ユーザー cielciel
提出日時 2017-06-13 21:55:21
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 227 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 11,892 KB
実行使用メモリ 16,840 KB
最終ジャッジ日時 2023-10-24 21:51:42
合計ジャッジ時間 7,750 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
16,052 KB
testcase_01 WA -
testcase_02 AC 77 ms
16,052 KB
testcase_03 AC 78 ms
16,052 KB
testcase_04 WA -
testcase_05 AC 126 ms
16,312 KB
testcase_06 AC 296 ms
16,576 KB
testcase_07 AC 217 ms
16,576 KB
testcase_08 AC 111 ms
16,088 KB
testcase_09 AC 78 ms
16,052 KB
testcase_10 AC 287 ms
16,588 KB
testcase_11 AC 168 ms
16,312 KB
testcase_12 AC 134 ms
16,312 KB
testcase_13 AC 324 ms
16,576 KB
testcase_14 AC 115 ms
16,312 KB
testcase_15 AC 160 ms
16,304 KB
testcase_16 AC 78 ms
16,052 KB
testcase_17 AC 126 ms
16,312 KB
testcase_18 AC 146 ms
16,312 KB
testcase_19 AC 79 ms
16,052 KB
testcase_20 AC 107 ms
16,088 KB
testcase_21 AC 353 ms
16,616 KB
testcase_22 AC 221 ms
16,576 KB
testcase_23 AC 301 ms
16,576 KB
testcase_24 AC 91 ms
16,052 KB
testcase_25 WA -
testcase_26 AC 173 ms
16,312 KB
testcase_27 AC 186 ms
16,308 KB
testcase_28 WA -
testcase_29 AC 377 ms
16,840 KB
testcase_30 AC 79 ms
16,052 KB
testcase_31 AC 79 ms
16,052 KB
testcase_32 AC 79 ms
16,052 KB
testcase_33 AC 80 ms
16,052 KB
testcase_34 AC 80 ms
16,052 KB
testcase_35 AC 166 ms
16,312 KB
testcase_36 WA -
testcase_37 AC 129 ms
16,312 KB
testcase_38 AC 143 ms
16,308 KB
testcase_39 AC 142 ms
16,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

bag=[1]
s=0
gets.to_i.times{
	v,w=gets.split.map(&:to_i)
	(s+=w).downto(w){|i|
		bag[i]=[bag[i]||0,(bag[i-w]||0)+v].max
	}
}
v=gets.to_i
p idx=bag.index(v+1)
idx=(idx...bag.size).find{|i|(bag[i]||0)>v+1}
puts idx ? idx-1 : :inf
0