{"id":1070,"date":"2024-08-12T09:00:00","date_gmt":"2024-08-12T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1070"},"modified":"2024-07-08T18:24:41","modified_gmt":"2024-07-08T10:24:41","slug":"zerojudge-c907","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-c907\/","title":{"rendered":"ZeroJudge C907: \u5c0b\u627e\u6700\u5927\u77e9\u5f62"},"content":{"rendered":"\n\n\n<p>\u73fe\u6709 N \u500b\u5bec\u5ea6\u70ba 1 \u55ae\u4f4d\u7684\u9577\u689d\u5716 (\u4f8b\u5982\u4e0b\u5716\u6240\u793a)\uff0c\u8a66\u6c42\u6b64\u9577\u689d\u5716\u4e2d\u53ef\u4ee5\u5f62\u6210\u7684\u6700\u5927\u77e9\u5f62\u9762\u7a4d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img decoding=\"async\" width=\"684\" height=\"426\" loading=\"lazy\" src=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1.png\" alt=\"ZeroJudge C907 \u984c\u76ee\u6558\u8ff0\" class=\"wp-image-1071\" srcset=\"https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1.png 684w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1-300x187.png 300w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1-18x12.png 18w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1-50x31.png 50w, https:\/\/seanxd.com\/wp-content\/uploads\/2024\/07\/image-1-100x62.png 100w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/figure>\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>\u4e00\u7b46\u6e2c\u8cc7\uff0c\u7b2c\u4e00\u884c\u8f38\u5165\u6574\u6578 N\uff0c\u63a5\u4e0b\u4f86\u6709 N \u884c\uff0c\u6bcf\u884c 1 \u500b\u6578\u5b57 H\uff0c\u4f9d\u5e8f\u4ee3\u8868\u6bcf\u500b\u9577\u689d\u5716\u7684\u9ad8\u5ea6\u3002(1 &lt;= N\u3001H &lt;= 10000)<\/td><td>\u8f38\u51fa\u6700\u5927\u77e9\u5f62\u9762\u7a4d<\/td><\/tr><tr><td>12<br>2<br>3<br>4<br>8<br>5<br>2<br>4<br>3<br>3<br>4<br>5<br>1<\/td><td>22<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u4f7f\u7528 Map \u4f86\u7d00\u9304\u6709\u51fa\u73fe\u7684\u9ad8\u5ea6\uff0c\u7136\u5f8c\u8dd1\u4e00\u500b for (auto it:Map) \u4f86\u5224\u65b7\u6bcf\u4e00\u7a2e\u9ad8\u5ea6\u7684\u6700\u5927\u77e9\u5f62\u9762\u7a4d\uff0c\u88e1\u9762\u518d\u8dd1\u4e00\u500b For\u8ff4\u5708 \u5f9e 0 \u5230 N-1\uff0c\u4e26\u4e14\u5728\u8ff4\u5708\u5916\u8a2d\u7f6e\u4e00\u500b\u8b8a\u6578 count \u9810\u8a2d\u70ba 0\uff0c\u5982\u679c\u6709\u4e2d\u65b7\u7684\u60c5\u6cc1\uff0c\u5247\u8981\u5c07 count \u6b78\u96f6\uff0c\u5728\u6b78\u96f6\u4e4b\u524d\u8981\u8a08\u7b97 count*\u76ee\u524d\u5224\u65b7\u7684\u9ad8\u5ea6\u4e26\u5224\u65b7\u6700\u5927\u503c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c907\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C907: \u5c0b\u627e\u6700\u5927\u77e9\u5f62<\/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;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, num[20000] = {}, ans = -999;\n    cin &gt;&gt; N;\n    map&lt;int, int&gt;MAP;\n    for (int i = 0; i&lt;N; i++) {\n        cin &gt;&gt; num[i];\n        MAP[num[i]]++;\n    }\n    for (auto it:MAP) {\n        const int height = it.first;\n        int count = 0;\n        for (int i = 0; i&lt;N; i++) {\n            if (num[i] &lt; height) {\n                ans = max(ans, count*height);\n                count = 0;\n                continue;\n            }\n            count++;\n        }\n        ans = max(ans, count*height);\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge C907\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u73fe\u6709 N \u500b\u5bec\u5ea6\u70ba 1 \u55ae\u4f4d\u7684\u9577\u689d\u5716 (\u4f8b\u5982\u4e0b\u5716\u6240\u793a)\uff0c\u8a66\u6c42\u6b64\u9577\u689d\u5716\u4e2d\u53ef\u4ee5\u5f62\u6210\u7684\u6700\u5927\u77e9\u5f62\u9762\u7a4d\u3002 \u7bc4\u4f8b\u6e2c\u8cc7 \u7bc4\u4f8b [&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":[29],"tags":[14,23,20,8,13,9],"class_list":["post-1070","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-map","tag-pair","tag-20","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1070","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=1070"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1073,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1070\/revisions\/1073"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}