{"id":40,"date":"2016-05-06T19:53:55","date_gmt":"2016-05-06T11:53:55","guid":{"rendered":"http:\/\/tyswly.com\/?p=40"},"modified":"2016-05-06T19:53:55","modified_gmt":"2016-05-06T11:53:55","slug":"noip2009%e5%bc%80%e5%bf%83%e7%9a%84%e9%87%91%e6%98%8e","status":"publish","type":"post","link":"https:\/\/tys.fun\/?p=40","title":{"rendered":"[NOIP2009]\u5f00\u5fc3\u7684\u91d1\u660e"},"content":{"rendered":"<p>\u9898\u76ee\u53c2\u89c1<a href=\"http:\/\/cogs.pro\/cogs\/problem\/problem.php?pid=71\">COGS<\/a>\u6216<a href=\"http:\/\/www.luogu.org\/problem\/show?pid=1060\">\u6d1b\u8c37<\/a><br \/>\n\u8bdd\u8bf4\u4e3a\u4ec0\u4e48\u8981\u5237\u8fd9\u4e48\u6c34\u768401\u80cc\u5305\u554a\u3002\u3002\u3002\/\/<del>\u8fd8\u4e0d\u662f\u4e3a\u5237\u6d1b\u8c37\u8bd5\u70bc\u573a\u63d0\u9ad8\u7ec4\u505a\u94fa\u57ab<\/del><br \/>\n\u5728\u8fd9\u91cc\u5949\u529d\u5927\u5bb6\u73cd\u7231\u751f\u547d\uff0c\u8fdc\u79bb\u6c34\u9898\u3002<br \/>\n\u8fd9\u4e48\u6c34\u7684\u9898\u5c31\u4e0d\u52a0\u6ce8\u91ca\u4e86\u3002<\/p>\n<pre class=\"lang:c++ decode:true \">#include &lt;iostream&gt;\n#include &lt;cstdio&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\nstruct node\n{\n\tint v, p, t;\n}fa[30];\nint n, m;\nint a[30][100005];\nint main()\n{\n\t\/\/freopen(\"happy.in\",\"r\",stdin);\n\t\/\/freopen(\"happy.out\",\"w\",stdout);\n\tcin&gt;&gt;n&gt;&gt;m;\n\tfor(int i=1;i&lt;=m;i++)\n\t{\n\t\tscanf(\"%d%d\",&amp;fa[i].p,&amp;fa[i].v);\n\t\tfa[i].t=fa[i].v*fa[i].p;\n\t}\n\tfor(int i=1;i&lt;=m;i++)\n\t{\n\t\tfor(int j=1;j&lt;=n;j++)\n\t\t{\n\t\t\tif(j&gt;=fa[i].p)\n\t\t\t{\n\t\t\t\ta[i][j]=max(a[i-1][j],a[i-1][j-fa[i].p]+fa[i].t);\n\t\t\t}\n\t\t\telse\n\t\t\t\ta[i][j]=a[i-1][j];\n\t\t}\n\t}\n\tcout&lt;&lt;a[m][n]&lt;&lt;\"\\n\";\n\treturn 0;\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u53c2\u89c1COGS\u6216\u6d1b\u8c37 \u8bdd\u8bf4\u4e3a\u4ec0\u4e48\u8981\u5237\u8fd9\u4e48\u6c34\u768401\u80cc\u5305\u554a\u3002\u3002\u3002\/\/\u8fd8\u4e0d\u662f\u4e3a\u5237\u6d1b\u8c37\u8bd5\u70bc\u573a\u63d0\u9ad8\u7ec4\u505a\u94fa\u57ab \u5728\u8fd9\u91cc\u5949\u529d &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-report"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":0,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}