{"id":362,"date":"2011-08-05T14:50:00","date_gmt":"2011-08-05T06:50:00","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=362"},"modified":"2020-06-06T14:51:31","modified_gmt":"2020-06-06T06:51:31","slug":"%e5%8f%96%e6%95%b0%e5%ad%97-%e5%8a%a8%e6%80%81%e8%a7%84%e5%88%92","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=362","title":{"rendered":"\u53d6\u6570\u5b57 \u52a8\u6001\u89c4\u5212"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/*\n \u586b\u8868\n \u5148\u586b\u7b2c\u4e00\u884c\n \u7136\u540e\u4e00\u76f4\u586b\u5230\u6700\u540e\u4e00\u884c\n \u9075\u5faa\u53ea\u586b\u5927\u6570\u7684\u539f\u5219\n \u6700\u540e\u8f93\u51fa\u8868\u5c3e\u5143\u7d20\u5373\u53ef \n *\/\n#define LOCAL\n#include&lt;iostream>\n#define N 100 \nusing namespace std;\nint a&#91;N]&#91;N], opt&#91;N]&#91;N];\nvoid nummax(int m, int n)\n{\n\tint i, j;\n\topt&#91;0]&#91;0] = a&#91;0]&#91;0];\n\tfor (i = 1; i &lt; n; i++)\n\t\topt&#91;0]&#91;i] = opt&#91;0]&#91;i - 1] + a&#91;0]&#91;i];\n\tfor (i = 1; i &lt; m; i++)\n\t{\n\t\topt&#91;i]&#91;0] = opt&#91;i - 1]&#91;0] + a&#91;i]&#91;0];\n\t\tfor (j = 1; j &lt; n; j++)\n\t\t\topt&#91;i]&#91;j] = a&#91;i]&#91;j]\n\t\t\t\t\t+ (opt&#91;i - 1]&#91;j] > opt&#91;i]&#91;j - 1] ?\n\t\t\t\t\t\t\topt&#91;i - 1]&#91;j] : opt&#91;i]&#91;j - 1]);\n\t}\n}\nint main()\n{\n#ifdef LOCAL\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\n\tint m, n, i, j;\n\twhile (cin >> m >> n)\n\t{\n\t\tfor (i = 0; i &lt; m; i++)\n\t\t\tfor (j = 0; j &lt; n; j++)\n\t\t\t\tcin >> a&#91;i]&#91;j];\n\t\tmemset(opt, 0, sizeof(opt));\n\t\tnummax(m, n);\n\t\t\/*\n\t\t for(i=0;i&lt;m;i++)\n\t\t {\n\t\t for(j=0;j&lt;n;j++)\n\t\t {\n\t\t cout&lt;&lt;a&#91;i]&#91;j]&lt;&lt;\" \";\t\t\n\t\t }\t\n\t\t cout&lt;&lt;endl;\n\t\t }\n\t\t for(i=0;i&lt;m;i++)\n\t\t {\n\t\t for(j=0;j&lt;n;j++)\n\t\t {\n\t\t cout&lt;&lt;opt&#91;i]&#91;j]&lt;&lt;\" \";\t\t\n\t\t }\t\n\t\t cout&lt;&lt;endl;\n\t\t }\n\t\t *\/\n\t\tcout &lt;&lt; opt&#91;m - 1]&#91;n - 1] &lt;&lt; endl;\n\t}\n\treturn 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-362","post","type-post","status-publish","format-standard","hentry","category-06-03-play-ground"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/362","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=362"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/362\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}