{"id":577,"date":"2024-06-16T09:00:00","date_gmt":"2024-06-16T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=577"},"modified":"2024-05-12T11:23:25","modified_gmt":"2024-05-12T03:23:25","slug":"zerojudge-c094","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-c094\/","title":{"rendered":"ZeroJudge C094: Blowing Fuses"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 00661 &#8211; Blowing Fuses<\/h4>\n\n\n\n<p class=\"\">\u5728\u5bb6\u5ead\u4e2d\u6211\u5011\u5076\u723e\u6703\u9047\u5230\u9019\u6a23\u7684\u72c0\u6cc1\uff1a\u5728\u4f60\u6253\u958b\u4e00\u4e9b\u5bb6\u5ead\u96fb\u5668\uff0c\u5982\uff1a\u96fb\u71c8\uff0c\u96fb\u8996\uff0c\u6d17\u8863\u6a5f \u2026\u2026 \u4e4b\u5f8c\uff0c\u7576\u4f60\u6253\u958b\u5fae\u6ce2\u7210\u7684\u4e00\u77ac\u9593\uff0c\u8df3\u96fb\u4e86\u3002\u56e0\u70ba\u96fb\u529b\u4f7f\u7528\u904e\u591a\u8d85\u904e\u4fdd\u96aa \u7d72\u7684\u6700\u9ad8\u8ca0\u8f09\u3002\u7576\u7136\uff0c\u9019\u662f\u4e00\u7a2e\u5b89\u5168\u63aa\u65bd\uff0c\u907f\u514d\u96fb\u7dda\u904e\u71b1\u71d2\u6389\u623f\u5b50\u3002\u4f46\u662f\uff0c<strong>\u5982\u679c\u5728\u6211\u5011\u6253\u958b\u96fb\u5668\u958b\u95dc\u4e4b\u524d\u53ef\u4ee5\u77e5\u9053\u6253\u958b\u4e4b\u5f8c\u662f\u5426\u6703\u9020\u6210\u4fdd\u96aa\u7d72\u71d2\u6389<\/strong>\uff0c\u90a3\u4e0d\u662f\u5f88\u597d\u55ce\uff1f<br>\u9019\u500b\u7a0b\u5f0f\u7684\u4efb\u52d9\u5c31\u662f\u8981\u6aa2\u67e5<strong>\u6253\u958b\u67d0\u4e9b\u96fb\u5668\u958b\u95dc\u4e4b\u5f8c<\/strong>\uff0c\u6240\u6709\u4f7f\u7528\u4e2d\u7684\u96fb\u5668\u5176\u7e3d\u7528\u96fb\u91cf<strong>\u662f\u5426\u6703\u8d85\u904e\u4fdd\u96aa\u7d72\u7684\u5bb9\u91cf<\/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><strong>EOF<\/strong> \u8f38\u5165\uff0c\u6bcf\u7b46\u6e2c\u8a66\u8cc7\u6599\u7684\u7b2c\u4e00\u884c\u67093\u500b\u6574\u6578 N\u3001M\u3001C\uff0cN \u4ee3\u8868\u7e3d\u5171\u6709\u591a\u5c11\u500b\u96fb\u5668\u7528\u54c1 (N &lt;= 20\uff09\uff0cM \u4ee3\u8868\u5171\u6709\u591a\u5c11\u6b21\u96fb\u5668\u7528\u54c1\u958b\u95dc\u7684\u52d5\u4f5c\uff0cC \u4ee3\u8868\u4fdd\u96aa\u7d72\u7684\u5bb9\u91cf\u3002<br>\u63a5\u4e0b\u4f86\u7684 N \u884c\u5404\u6709\u4e00\u500b\u6574\u6578 i\uff0c\u5206\u5225\u4ee3\u8868\u7b2c 1 \u500b\u96fb\u5668\uff0c\u7b2c 2 \u500b\u96fb\u5668 \u2026\u2026 \u7b2c N \u500b\u96fb\u5668\u7528\u54c1\u4f7f\u7528\u6642\u9700\u8981\u7684\u96fb\u6d41\u3002<br>\u518d\u63a5\u4e0b\u4f86\u7684\u7684 M \u884c\uff0c\u6bcf\u884c\u6709\u4e00\u500b\u4ecb\u65bc 1 \u5230 N \u4e4b\u9593\u7684\u6574\u6578 K\uff0c\u4ee3\u8868\u958b\/\u95dc\u7b2c K \u500b\u96fb\u5668\u7528\u54c1\u3002\u6ce8\u610f\uff1a\u5c0d\u540c\u4e00\u500b\u96fb\u5668\u7528\u54c1\uff0c\u7b2c\u4e00\u6b21\u52d5\u4f5c\u70ba\u958b\uff0c\u7b2c\u4e8c\u6b21\u52d5\u4f5c\u70ba\u95dc\uff0c\u4f9d\u6b64\u985e\u63a8\u3002\u5047\u8a2d\u4e00\u958b\u59cb\u6642\u6240\u6709\u7684\u96fb\u5668\u7528\u54c1\u7684\u72c0\u614b\u5747\u70ba\u95dc\u8457\u7684\u3002<br>N = M = C = 0\u4ee3\u8868\u8f38\u5165\u7d50\u675f\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u7b46\u6e2c\u8a66\u8cc7\u6599\uff0c\u5982\u679c\u4fdd\u96aa\u7d72\u71d2\u6389\uff0c\u8acb\u8f38\u51fa\uff1a\u300cFuse was blown.\u300d\u3002<br>\u5982\u679c\u4fdd\u96aa\u7d72\u6c92\u6709\u71d2\u6389\uff0c\u8acb\u8f38\u51fa\uff1a\u300cFuse was not blown.\u300d\u4e26\u4e14<strong>\u8f38\u51fa\u5728\u958b\u95dc\u7684\u904e\u7a0b\u4e2d\u51fa\u73fe\u7684\u6700\u5927\u7e3d\u7528\u96fb\u91cf<\/strong>\u3002<br>\u6bcf\u7d44\u6e2c\u8a66\u8cc7\u6599\u5f8c\u8acb\u8f38\u51fa\u4e00\u7a7a\u767d\u5217\u3002\u8acb\u53c3\u8003Sample output\u3002<\/td><\/tr><tr><td>2 2 10<br>5<br>7<br>1<br>2<br>3 6 10<br>2<br>5<br>7<br>2<br>1<br>2<br>3<br>1<br>3<br>0 0 0<\/td><td>Sequence 1<br>Fuse was blown.<br><br>Sequence 2<br>Fuse was not blown.<br>Maximal power consumption was 9 amperes.<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge C094 \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 class=\"\">\u4f7f\u7528 Map \u4f86\u7d00\u9304\u76ee\u524d\u7684\u96fb\u5668\u7528\u54c1\u662f\u958b\u9084\u662f\u95dc\uff0cMap&lt;int, int> \u5ba3\u544a\u7684\u6642\u5019\u6240\u6709\u7684 Value \u503c\u90fd\u662f\u9810\u8a2d\u70ba 0\u3002<\/p>\n\n\n\n<p class=\"\">\u6bcf\u7b46\u6e2c\u8cc7\u4e2d\u9593\u90fd\u8981\u63db\u884c\uff0c\u4f46\u662f\u6700\u5f8c\u4e00\u7b46\u6e2c\u8cc7\u4e4b\u5f8c\u4e0d\u80fd\u518d\u63db\u884c\u3002\u53ef\u4ee5\u5ba3\u544a\u4e00\u500b count \u8b8a\u6578\u7d00\u9304\u76ee\u524d\u7684 sequence \u662f\u591a\u5c11\uff0c\u6539\u7528\u73fe\u5728\u5148\u8f38\u51fa\u4e0a\u4e00\u500b\u6e2c\u8cc7\u7684\u63db\u884c\u3002\u6240\u4ee5\u5982\u679c count != 1 \u7684\u60c5\u6cc1\u4e0b\uff0c\u5c31\u5148\u8f38\u51fa\u4e00\u500b\u63db\u884c\u518d\u8f38\u51fa sequence \u662f\u591a\u5c11\u8ddf\u662f\u5426\u6709\u71d2\u58de\u4fdd\u96aa\u7d72\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=c094\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge C094: Blowing Fuses<\/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;map&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, C, count = 1;\n    while (cin &gt;&gt; N &gt;&gt; M &gt;&gt; C && N != 0 && M != 0 && C != 0)\n    {\n        vector&lt;int&gt;num;\n        num.push_back(-1);\n        int power = 0, max = -9999;\n        map&lt;int, int&gt;MAP;\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        bool blown = false;\n        for (int i = 0; i&lt;M; i++)\n        {\n            int tmp;\n            cin &gt;&gt; tmp;\n            if (MAP[tmp] == 0)\n            {\n                MAP[tmp]++;\n                power += num[tmp];\n            }\n            else\n            {\n                MAP[tmp]--;\n                power -= num[tmp];\n            }\n            if (power &gt; C) blown = true;\n            if (power &gt; max) max = power;\n        }\n        if (count != 1) cout &lt;&lt; &quot;\\n&quot;;\n        cout &lt;&lt; &quot;Sequence &quot; &lt;&lt; count &lt;&lt; &quot;\\n&quot;;\n        if (blown) cout &lt;&lt; &quot;Fuse was blown.\\n&quot;;\n        else cout &lt;&lt; &quot;Fuse was not blown.\\nMaximal power consumption was &quot; &lt;&lt; max &lt;&lt; &quot; amperes.\\n&quot;;\n        count++;\n    }\n}\n\n\/\/ZeroJudge C094\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 00661 &#8211; Blowing Fuses \u5728\u5bb6\u5ead\u4e2d\u6211\u5011\u5076\u723e\u6703\u9047\u5230\u9019\u6a23\u7684\u72c0\u6cc1\uff1a\u5728\u4f60\u6253 [&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":[18],"tags":[14,20,8,34,9],"class_list":["post-577","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-20","tag-8","tag-34","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/577","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=577"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/577\/revisions"}],"predecessor-version":[{"id":579,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/577\/revisions\/579"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}