{"id":477,"date":"2024-05-13T09:00:00","date_gmt":"2024-05-13T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=477"},"modified":"2024-05-13T12:23:21","modified_gmt":"2024-05-13T04:23:21","slug":"zerojudge-g595","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-g595\/","title":{"rendered":"ZeroJudge G595: \u4fee\u88dc\u570d\u7c6c"},"content":{"rendered":"\n\n\n<p class=\"\">\u6709\u4e00\u500b\u8fb2\u5834\u6709\u5bec\u5ea6\u70ba N \u7684\u570d\u7c6c\uff0c\u6bcf\u500b\u570d\u7c6c\u90fd\u6709\u5404\u81ea\u7684\u9ad8\u5ea6 H<sub>1<\/sub>\uff5eH<sub>N<\/sub>\u3002<\/p>\n\n\n\n<p class=\"\">\u6709\u4e9b\u570d\u7c6c\u88ab\u5439\u65b7\u4e86\uff0c\u8fb2\u5834\u4e3b\u4eba\u8981\u4f86\u4fee\u88dc\u9019\u4e9b\u570d\u7c6c\uff0c\u4f46\u4ed6\u5fd8\u8a18\u9019\u4e9b\u58de\u6389\u7684\u570d\u7c6c\u539f\u672c\u9ad8\u5ea6\u662f\u591a\u5c11\uff0c\u70ba\u4e86\u6e1b\u5c11\u6210\u672c\uff0c\u4ed6\u6703<strong>\u53d6\u65b7\u6389\u7684\u570d\u7c6c\u4f4d\u7f6e\u76f8\u9130\u5de6\u908a\u548c\u53f3\u908a\u8f03\u5c0f\u7684\u90a3\u500b\u9ad8\u5ea6\u586b\u4e0a\u53bb<\/strong>\uff0c\u554f\u9700\u8981\u591a\u5c11\u6210\u672c<\/p>\n\n\n\n<p class=\"\">\u984c\u76ee\u4fdd\u8b49\u4e0d\u6703\u6709\u5169\u500b\u76f8\u9130\u7684\u5439\u65b7\u570d\u7c6c\uff0c\u800c<strong>\u7a7f\u65b7\u7684\u570d\u7c6c\u6709\u53ef\u80fd\u4f4d\u5728\u908a\u754c<\/strong>\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 nfd-wb-animate nfd-wb-fade-in-bottom-short\"><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\u5305\u542b\u5169\u884c<br>\u7b2c\u4e00\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 N<br>\u7b2c\u4e8c\u884c\u6709 N \u500b\u4ee5\u7a7a\u9694\u5206\u9694\u7684\u6574\u6578 H<sub>1<\/sub>\uff5eH<sub>N<\/sub><\/td><td>\u8f38\u51fa\u4e00\u500b\u6b63\u6574\u6578\u8868\u793a\u65b0\u589e\u7684\u570d\u7c6c\u9577\u5ea6\u7e3d\u548c<\/td><\/tr><tr><td>3<br>2  0  4<\/td><td>2<\/td><\/tr><tr><td>9<br>0  5  3  0  6  4  0  1  0<\/td><td>10<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u5c07<strong>\u67f5\u6b04\u7684\u9ad8\u5ea6\u5b58\u5230\u4e00\u500b\u9663\u5217\u88e1<\/strong>\uff0c\u4e26\u4e14<strong>\u8dd1\u4e00\u500b For\u8ff4\u5708 \u5f9e 0 \u5230 N-1<\/strong>\u3002\u5982\u679c H[i] \u662f 0 \u7684\u8a71\u5c31\u8981\u5224\u65b7\u5de6\u53f3\u5169\u908a\u54ea\u908a\u6bd4\u8f03\u4f4e\u4e26\u52a0\u5230\u7b54\u6848\u88e1\u3002<\/p>\n\n\n\n<p class=\"\">\u5982\u679c<strong>\u76ee\u524d\u7684 i \u662f\u4f4d\u65bc\u908a\u754c (0 \u6216\u662f N-1)<\/strong>\uff0c\u4e0d\u9700\u8981\u5224\u65b7\u5927\u5c0f<strong>\u76f4\u63a5\u628a\u53e6\u5916\u4e00\u908a\u7684\u67f5\u6b04\u9577\u5ea6\u52a0\u5230\u7b54\u6848<\/strong>\u88e1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=g595\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge G595: \u4fee\u88dc\u570d\u7c6c<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><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, ans = 0;\n    cin &gt;&gt; N;\n    vector&lt;int&gt;num;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int tmp;\n        cin &gt;&gt; tmp;\n        num.push_back(tmp);\n    }\n    for (int i = 0; i&lt;N; i++)\n    {\n        if (num[i] == 0)\n        {\n            if (i == 0)\n            {\n                ans += num[i+1];\n                continue;\n            }\n            if (i == N-1)\n            {\n                ans += num[i-1];\n                continue;\n            }\n            ans += min(num[i+1], num[i-1]);\n        }\n    }\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge G595\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e00\u500b\u8fb2\u5834\u6709\u5bec\u5ea6\u70ba N \u7684\u570d\u7c6c\uff0c\u6bcf\u500b\u570d\u7c6c\u90fd\u6709\u5404\u81ea\u7684\u9ad8\u5ea6 H1\uff5eHN\u3002 \u6709\u4e9b\u570d\u7c6c\u88ab\u5439\u65b7\u4e86\uff0c\u8fb2\u5834\u4e3b\u4eba\u8981\u4f86\u4fee\u88dc\u9019\u4e9b\u570d [&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-477","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\/477","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=477"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/477\/revisions"}],"predecessor-version":[{"id":585,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/477\/revisions\/585"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}