{"id":224,"date":"2016-09-08T19:57:11","date_gmt":"2016-09-08T11:57:11","guid":{"rendered":"http:\/\/kylelv.com\/?p=224"},"modified":"2017-12-13T12:56:03","modified_gmt":"2017-12-13T04:56:03","slug":"bzoj-1625-usaco2007-dec%e5%ae%9d%e7%9f%b3%e6%89%8b%e9%95%af","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=224","title":{"rendered":"bzoj 1625: [Usaco2007 Dec]\u5b9d\u77f3\u624b\u956f"},"content":{"rendered":"<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdef7495930\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdef7495930\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#1625_Usaco2007_Dec%E5%AE%9D%E7%9F%B3%E6%89%8B%E9%95%AF\" title=\"1625: [Usaco2007 Dec]\u5b9d\u77f3\u624b\u956f\">1625: [Usaco2007 Dec]\u5b9d\u77f3\u624b\u956f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=224\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1625_Usaco2007_Dec%E5%AE%9D%E7%9F%B3%E6%89%8B%E9%95%AF\"><\/span>1625: [Usaco2007 Dec]\u5b9d\u77f3\u624b\u956f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a0<\/span>5 Sec\u00a0\u00a0<span class=\"green\">Memory Limit:\u00a0<\/span>64 MB<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u8d1d\u831c\u5728\u73e0\u5b9d\u5e97\u95f2\u901b\u65f6\uff0c\u4e70\u5230\u4e86\u4e00\u4e2a\u4e2d\u610f\u7684\u624b\u956f\u3002\u5f88\u81ea\u7136\u5730\uff0c\u5979\u60f3\u4ece\u5979\u6536\u96c6\u7684 N(1 &lt;= N &lt;= 3,402)\u5757\u5b9d\u77f3\u4e2d\u9009\u51fa\u6700\u597d\u7684\u90a3\u4e9b\u9576\u5728\u624b\u956f\u4e0a\u3002\u5bf9\u4e8e\u7b2ci\u5757\u5b9d\u77f3\uff0c\u5b83\u7684\u91cd\u91cf\u4e3aW_i(1 &lt;= W_i &lt;= 400)\uff0c\u5e76\u4e14\u8d1d\u831c\u77e5\u9053\u5b83\u5728\u9576\u4e0a\u624b\u956f\u540e\u80fd\u4e3a\u81ea\u5df1\u589e\u52a0\u7684\u9b45\u529b\u503cD_i(1 &lt;= D_i &lt;= 100)\u3002\u7531\u4e8e\u8d1d\u831c\u53ea\u80fd\u5fcd\u53d7\u91cd\u91cf\u4e0d\u8d85\u8fc7M(1 &lt;= M &lt;= 12,880)\u7684\u624b\u956f\uff0c\u5979\u53ef\u80fd\u65e0\u6cd5\u628a\u6240\u6709\u559c\u6b22\u7684\u5b9d\u77f3\u90fd\u9576\u4e0a\u3002 \u4e8e\u662f\u8d1d\u831c\u627e\u5230\u4e86\u4f60\uff0c\u544a\u8bc9\u4e86\u4f60\u5979\u6240\u6709\u5b9d\u77f3\u7684\u5c5e\u6027\u4ee5\u53ca\u5979\u80fd\u5fcd\u53d7\u7684\u91cd\u91cf\uff0c\u5e0c\u671b\u4f60\u80fd\u5e2e\u5979\u8ba1\u7b97\u4e00\u4e0b\uff0c\u6309\u7167\u6700\u5408\u7406\u7684\u65b9\u6848\u9576\u5d4c\u5b9d\u77f3\u7684\u8bdd\uff0c\u5979\u7684\u9b45\u529b\u503c\u6700\u591a\u80fd\u589e\u52a0\u591a\u5c11\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>* \u7b2c1\u884c: 2\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570\uff1aN \u548c M<\/p>\n<p>* \u7b2c2..N+1\u884c: \u7b2ci+1\u884c\u4e3a2\u4e2a\u7528\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570\uff1aW_i\u3001D_i\uff0c\u5206\u522b\u4e3a\u7b2ci\u5757\u5b9d\u77f3 \u7684\u91cd\u91cf\u4e0e\u80fd\u4e3a\u8d1d\u831c\u589e\u52a0\u7684\u9b45\u529b\u503c<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>* \u7b2c1\u884c: \u8f93\u51fa1\u4e2a\u6574\u6570\uff0c\u8868\u793a\u6309\u7167\u9576\u5d4c\u8981\u6c42\uff0c\u8d1d\u831c\u6700\u591a\u80fd\u589e\u52a0\u7684\u9b45\u529b\u503c<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\"><span class=\"sampledata\">4 6<br \/>\n1 4<br \/>\n2 6<br \/>\n3 12<br \/>\n2 7<\/span><\/span>\u8f93\u5165\u8bf4\u660e:\u8d1d\u831c\u6536\u96c6\u4e864\u5757\u5b9d\u77f3\uff0c\u5979\u80fd\u5fcd\u53d7\u91cd\u91cf\u6700\u5927\u4e3a6\u7684\u624b\u956f\u3002<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p><span class=\"sampledata\">23<\/span><\/p>\n<p>\u8f93\u51fa\u8bf4\u660e:<\/p>\n<p>\u8d1d\u831c\u628a\u9664\u4e86\u7b2c\u4e8c\u5757\u5b9d\u77f3\u7684\u5176\u4f59\u6240\u6709\u5b9d\u77f3\u90fd\u9576\u4e0a\u624b\u956f\uff0c\u8fd9\u6837\u5979\u80fd\u589e\u52a0<br \/>\n4+12+7=23\u7684\u9b45\u529b\u503c\uff0c\u5e76\u4e14\u6240\u6709\u5b9d\u77f3\u7684\u91cd\u91cf\u4e3a1+2+3 &lt;= 6\uff0c\u540c\u6837\u7b26\u5408\u8981\u6c42\u3002<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u3002\u3002\u6700\u7b80\u5355\u7684\u80cc\u5305\u95ee\u9898\u3002\u3002\u3002<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;iostream&gt;\r\nint dp[13000],n,m,w,d;\r\nusing namespace std;\r\nint main()\r\n{\r\n    cin&gt;&gt;n&gt;&gt;m;\r\n    for(int i=1;i&lt;=n;i++)\r\n    {\r\n        cin&gt;&gt;w&gt;&gt;d;\r\n        for(int j=m;j&gt;=w;j--)\r\n        dp[j]=max(dp[j],dp[j-w]+d);\r\n    }\r\n    cout&lt;&lt;dp[m];\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 1625: [Usaco2007 Dec]\u5b9d\u77f3\u624b\u956f Time Limit:\u00a05 Sec\u00a0\u00a0Mem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[5],"class_list":["post-224","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-dp"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=224"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/224\/revisions"}],"predecessor-version":[{"id":250,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/224\/revisions\/250"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}