<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>anton0825</author_name>
  <author_url>https://blog.hatena.ne.jp/anton0825/</author_url>
  <blog_title>日々精進</blog_title>
  <blog_url>https://anton0825.hatenablog.com/</blog_url>
  <categories>
    <anon>IT</anon>
  </categories>
  <description>今回のお題はこちら。 今回はdp用メモテーブル$dpのサイズを間違えて不具合になりました。 ナップサックに入れられる重さは0〜wなので、 配列のサイズはwじゃなくてw+1にしないといけないんですなー。 W = [2,1,3,2] #input V = [3,2,4,2] #input w = 5 #input INF = -1 $dp = Array.new( W.length ).map!{ Array.new( w + 1, INF ) } def maxValue(index, leftWeight) return $dp[index][leftWeight] unless $dp[in…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fanton0825.hatenablog.com%2Fentry%2F20110108%2F1293303600&quot; title=&quot;プログラミングコンテストチャレンジブック演習「ナップサック問題」 - 日々精進&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>http://cdn-ak.f.st-hatena.com/images/fotolife/a/anton0825/20101226/20101226035556.jpg</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2011-01-08 04:00:00</published>
  <title>プログラミングコンテストチャレンジブック演習「ナップサック問題」</title>
  <type>rich</type>
  <url>https://anton0825.hatenablog.com/entry/20110108/1293303600</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
