結果

問題 No.527 ナップサック容量問題
ユーザー 0w10w1
提出日時 2017-08-09 11:01:57
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,824 KB
最終ジャッジ日時 2024-04-20 08:29:04
合計ジャッジ時間 27,100 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
13,440 KB
testcase_01 AC 135 ms
13,440 KB
testcase_02 WA -
testcase_03 AC 135 ms
13,568 KB
testcase_04 AC 98 ms
13,440 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 974 ms
13,696 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,191 ms
13,440 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 487 ms
13,696 KB
testcase_15 AC 735 ms
13,440 KB
testcase_16 AC 139 ms
13,824 KB
testcase_17 AC 607 ms
13,696 KB
testcase_18 AC 689 ms
13,568 KB
testcase_19 AC 152 ms
13,696 KB
testcase_20 AC 531 ms
13,440 KB
testcase_21 AC 1,360 ms
13,824 KB
testcase_22 AC 945 ms
13,696 KB
testcase_23 AC 1,350 ms
13,568 KB
testcase_24 AC 328 ms
13,696 KB
testcase_25 AC 904 ms
13,440 KB
testcase_26 AC 814 ms
13,696 KB
testcase_27 AC 836 ms
13,568 KB
testcase_28 AC 734 ms
13,568 KB
testcase_29 AC 1,367 ms
13,568 KB
testcase_30 WA -
testcase_31 AC 630 ms
13,568 KB
testcase_32 AC 751 ms
13,568 KB
testcase_33 AC 652 ms
13,440 KB
testcase_34 AC 789 ms
13,696 KB
testcase_35 AC 788 ms
13,568 KB
testcase_36 AC 126 ms
13,440 KB
testcase_37 AC 598 ms
13,696 KB
testcase_38 AC 761 ms
13,440 KB
testcase_39 AC 693 ms
13,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A = $<.map { |s| s.split.map &:to_i }
N = A.shift[0]
VALUE = A.pop[0]
V, W = A.transpose
dp = [0] + [-1e9.to_i] * 10**5
N.times do |i|
  1e5.to_i.downto(W[i]) do |j|
    dp[j] = [dp[j], V[i] + dp[j - W[i]]].max
  end
end
_ = 0
1e5.to_i.times do |i|
  _ = [_, dp[i]].max
  dp[i] = [dp[i], _].max
end
p [1, dp.index(VALUE)].max
p dp[-1] == VALUE ? :inf : [1, dp.rindex(VALUE)].max
0