{"type":"rich","width":"100%","version":"1.0","author_url":"https://blog.hatena.ne.jp/anton0825/","url":"https://anton0825.hatenablog.com/entry/20110108/1293303600","published":"2011-01-08 04:00:00","categories":["IT"],"provider_name":"Hatena Blog","image_url":"http://cdn-ak.f.st-hatena.com/images/fotolife/a/anton0825/20101226/20101226035556.jpg","blog_title":"\u65e5\u3005\u7cbe\u9032","description":"\u4eca\u56de\u306e\u304a\u984c\u306f\u3053\u3061\u3089\u3002 \u4eca\u56de\u306fdp\u7528\u30e1\u30e2\u30c6\u30fc\u30d6\u30eb$dp\u306e\u30b5\u30a4\u30ba\u3092\u9593\u9055\u3048\u3066\u4e0d\u5177\u5408\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u30ca\u30c3\u30d7\u30b5\u30c3\u30af\u306b\u5165\u308c\u3089\u308c\u308b\u91cd\u3055\u306f0\u301cw\u306a\u306e\u3067\u3001 \u914d\u5217\u306e\u30b5\u30a4\u30ba\u306fw\u3058\u3083\u306a\u304f\u3066w+1\u306b\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3093\u3067\u3059\u306a\u30fc\u3002 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\u2026","blog_url":"https://anton0825.hatenablog.com/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fanton0825.hatenablog.com%2Fentry%2F20110108%2F1293303600\" title=\"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b3\u30f3\u30c6\u30b9\u30c8\u30c1\u30e3\u30ec\u30f3\u30b8\u30d6\u30c3\u30af\u6f14\u7fd2\u300c\u30ca\u30c3\u30d7\u30b5\u30c3\u30af\u554f\u984c\u300d - \u65e5\u3005\u7cbe\u9032\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","height":"190","provider_url":"https://hatena.blog","title":"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b3\u30f3\u30c6\u30b9\u30c8\u30c1\u30e3\u30ec\u30f3\u30b8\u30d6\u30c3\u30af\u6f14\u7fd2\u300c\u30ca\u30c3\u30d7\u30b5\u30c3\u30af\u554f\u984c\u300d","author_name":"anton0825"}