{"id":775,"date":"2024-07-17T09:00:00","date_gmt":"2024-07-17T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=775"},"modified":"2024-06-06T18:38:20","modified_gmt":"2024-06-06T10:38:20","slug":"zerojudge-k466","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-k466\/","title":{"rendered":"ZeroJudge K466: \u6210\u7e3e\u5206\u6790 (Analysis)"},"content":{"rendered":"\n\n\n<p>\u6700\u8fd1\u525b\u8003\u5b8c\u6bb5\u8003\uff0c\u70ba\u4e86\u8981\u9f13\u52f5\u73ed\u4e0a\u540c\u5b78\uff0c\u8001\u5e2b\u60f3\u8981\u7279\u5225\u9812\u767c\u79ae\u7269\u7d66\u6b77\u6b21\u6bb5\u8003\u4e2d<strong>\u9032\u6b65\u6700\u591a\u7684\u5b78\u751f<\/strong>\u3002\u53e6\u5916\uff0c\u8001\u5e2b\u4e5f<strong>\u60f3\u627e\u51fa\u9000\u6b65\u6700\u591a\u7684\u5b78\u751f<\/strong>\uff0c\u591a\u52a0\u95dc\u5fc3\u5b78\u751f\u7684\u5b78\u7fd2\u72c0\u6cc1\u3002<\/p>\n\n\n\n<p>\u8001\u5e2b\u6703\u5c07\u5b78\u751f\u6b77\u6b21\u8003\u8a66\u8f03\u524d\u6b21\u8003\u8a66\u9032\u6b65\u7684\u5206\u6578\u7e3d\u548c\u8a18\u70ba\u6b64\u5b78\u751f\u7684\u9032\u6b65\u5e45\u5ea6\uff0c\u800c\u8f03\u524d\u6b21\u8003\u8a66\u9000\u6b65\u7684\u5206\u6578\u7e3d\u548c\u5247\u8a18\u70ba\u5b78\u751f\u7684\u9000\u6b65\u5e45\u5ea6\u3002<\/p>\n\n\n\n<p>\u8209\u4f8b\u4f86\u8aaa\uff0c\u82e5\u4e00\u500b\u5b78\u751f\u524d\u4e94\u6b21\u7684\u6bb5\u8003\u6210\u7e3e\u5206\u5225\u70ba (80\u300190\u300160\u300170\u300165)\uff0c\u4ed6\u7684\u6bcf\u7b46\u5206\u6578\u8207\u524d\u6b21\u5206\u6578\u7684\u9032\u6b65\u5206\u4f9d\u5e8f\u70ba (10\u30010\u300110\u30010)\uff0c\u56e0\u6b64\u9032\u6b65\u5e45\u5ea6\u70ba 20\u3002\u6bcf\u7b46\u5206\u6578\u8207\u524d\u6b21\u5206\u6578\u7684\u9000\u6b65\u5206\u4f9d\u5e8f\u70ba (0\u300130\u30010\u30015)\uff0c\u56e0\u6b64\u9000\u6b65\u5e45\u5ea6\u70ba 35\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u8f38\u5165\u7b2c\u4e00\u5217\u70ba\u5169\u500b\u6574\u6578 N \u548c M (3 \u2264 N \u2264 1000\uff0c2 \u2264 M \u2264 100)\uff0c\u5206\u5225\u8868\u793a\u5b78\u751f\u4eba\u6578\u4ee5\u53ca\u8003\u8a66\u6b21\u6578\u3002\u63a5\u4e0b\u4f86\u6709 N \u5217\uff0c\u6bcf\u4e00\u5217\u6709 M \u500b\u6578\u5b57 S<sub>i<\/sub> (1 \u2264 S<sub>i<\/sub> \u2264 100\uff0c1 \u2264 i \u2264 M)\uff0c\u8868\u793a\u5ea7\u865f i \u7684\u5b78\u751f\u6b77\u6b21\u8003\u8a66\u6210\u7e3e\u3002<\/td><td>\u8f38\u51fa\u7b2c\u4e00\u5217\u8868\u793a\u6700\u4f73\u9032\u6b65\u7684\u5b78\u751f\u5ea7\u865f\uff0c\u7b2c\u4e8c\u5217\u8868\u793a\u6700\u9700\u95dc\u5fc3\u7684\u5b78\u751f\u5ea7\u865f\u3002<br><strong>\u82e5\u6709\u591a\u500b\u6700\u4f73\u9032\u6b65\u6216\u6700\u9700\u95dc\u5fc3\u7684\u5b78\u751f\u5247\u8f38\u51fa\u5ea7\u865f\u6700\u5c0f\u8005<\/strong>\u3002<\/td><\/tr><tr><td>3 5<br>80 90 60 70 65<br>70 60 65 60 55<br>40 50 60 70 80<\/td><td>3<br>1<\/td><\/tr><tr><td>3 3<br>74 44 98<br>11 75 14<br>62 19 32<\/td><td>2<br>2<\/td><\/tr><tr><td>4 4<br>33 51 10 76<br>69 90 69 91<br>17 55 59 64<br>46 82 60 26<\/td><td>1<br>4<\/td><\/tr><tr><td>8 3<br>3 83 13<br>92 45 67<br>70 19 11<br>46 78 86<br>98 61 26<br>68 78 40<br>48 94 3<br>44 9 39<\/td><td>1<br>7<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge K466 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u5c07\u6bcf\u500b\u5b78\u751f\u7684\u6210\u7e3e\u5b58\u5230\u9663\u5217\u4e2d\uff0c\u4e26\u4e14\u908a\u6536\u8cc7\u6599\u908a\u5224\u65b7\uff0c\u5982\u679c\u76ee\u524d\u6536\u5230\u7684\u8cc7\u6599\u975e\u6578\u5217\u7b2c\u4e00\u500b\u4f4d\u7f6e\uff0c\u5c31\u5224\u65b7\u6536\u5230\u7684\u8cc7\u6599\u662f\u6bd4\u524d\u9762\u7684\u8cc7\u6599\u5927\u9084\u662f\u5c0f\uff0c\u4e26\u4e14\u5ba3\u544a\u5169\u500b\u8b8a\u6578 up \u548c down \u9810\u8a2d\u70ba 0\uff0c\u5982\u679c\u662f\u9032\u6b65\u5c31\u5c07\u9032\u6b65\u7684\u5e45\u5ea6\u52a0\u5230 up\uff0c\u53cd\u4e4b\u5c07\u9000\u6b65\u7684\u5e45\u5ea6\u52a0\u5230 down\u3002<\/p>\n\n\n\n<p>\u5224\u65b7\u5b8c\u4e00\u500b\u5b78\u751f\u6240\u6709\u6210\u7e3e\u4e4b\u5f8c\u8981\u5224\u65b7\u5176\u9032\u6b65\u8207\u9000\u6b65\u5e45\u5ea6\u662f\u5426\u70ba\u5168\u73ed\u6700\u5927\uff0c\u56e0\u70ba\u53ef\u80fd\u6703\u6709\u9032\/\u9000\u6b65\u5e45\u5ea6\u76f8\u540c\u7684\u60c5\u6cc1\uff0c\u6240\u4ee5\u5224\u65b7\u7684\u6642\u5019\u8981\u4f7f\u7528 >\uff0c\u7576\u6709\u76f8\u540c\u5e45\u5ea6\u7684\u60c5\u6cc1\u4e0b\u5c31\u6703\u63a1\u7528\u8f03\u524d\u9762\u4e5f\u5c31\u662f\u5b78\u865f\u8f03\u5c0f\u7684\u5b78\u751f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=k466\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge K466: \u6210\u7e3e\u5206\u6790 (Analysis)<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    int increase = -1, increase_num = 0, decrease = -1, decrease_num = 0;\n    for (int i = 0; i&lt;N; i++) {\n        vector&lt;int&gt;num;\n        int up = 0, down = 0;\n        for (int j = 0; j&lt;M; j++) {\n            int tmp;\n            cin &gt;&gt; tmp;\n            num.push_back(tmp);\n            if (j &gt; 0) {\n                if (num[j] &gt; num[j-1]) up += num[j] - num[j-1];\n                if (num[j] &lt; num[j-1]) down += num[j-1] - num[j];\n            }\n        }\n        if (up &gt; increase) {\n            increase = up;\n            increase_num = i+1;\n        }\n        if (down &gt; decrease) {\n            decrease = down;\n            decrease_num = i+1;\n        }\n    }\n    cout &lt;&lt; increase_num &lt;&lt; &quot;\\n&quot; &lt;&lt; decrease_num &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge K466\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u525b\u8003\u5b8c\u6bb5\u8003\uff0c\u70ba\u4e86\u8981\u9f13\u52f5\u73ed\u4e0a\u540c\u5b78\uff0c\u8001\u5e2b\u60f3\u8981\u7279\u5225\u9812\u767c\u79ae\u7269\u7d66\u6b77\u6b21\u6bb5\u8003\u4e2d\u9032\u6b65\u6700\u591a\u7684\u5b78\u751f\u3002\u53e6\u5916\uff0c\u8001\u5e2b\u4e5f\u60f3\u627e\u51fa\u9000\u6b65\u6700\u591a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[25],"tags":[20,8,9],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-20","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":777,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/775\/revisions\/777"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}