{"id":1312,"date":"2024-12-21T09:00:00","date_gmt":"2024-12-21T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1312"},"modified":"2024-12-08T12:58:30","modified_gmt":"2024-12-08T04:58:30","slug":"zerojudge-b184","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-b184\/","title":{"rendered":"ZeroJudge B184: \u88dd\u8ca8\u6ac3\u554f\u984c"},"content":{"rendered":"\n\n\n<p>\u73fe\u5728\u4e00\u5171\u6709\u82e5\u5e72\u9805\u8ca8\u54c1\u53ef\u9078\u64c7\u904b\u8f09\uff0c\u6bcf\u4e00\u9805k\u90fd\u6709\u4e00\u500b\u5df2\u77e5\u7684\u9ad4\u7a4d v[k]\uff0c\u4ee5\u53ca\u8f09\u904b\u7684\u5229\u6f64 c[k]\uff0c\u4f46\u662f\u8ca8\u6ac3\u7684\u7e3d\u5bb9\u91cf\u662f 100\uff0c\u53ef\u80fd\u7121\u6cd5\u5c07\u8ca8\u7269\u5168\u90e8\u88dd\u5165\uff0c\u5e0c\u671b\u9078\u51fa\u5176\u4e2d\u7684\u82e5\u5e72\u9805\uff0c\u5176\u9ad4\u7a4d\u7e3d\u548c\u4e0d\u8d85\u904e 100\uff0c\u4f7f\u5f97\u5229\u6f64\u6700\u5927\u3002\uff08\u6bcf\u4e00\u9805\u8ca8\u7269\u7684\u9ad4\u7a4d\u70ba 1~100 \u7684\u6574\u6578\uff0c\u800c\u5229\u6f64\u662f 1~60000 \u7684\u6574\u6578\u3002\uff09<\/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>EOF \u8f38\u5165\uff0c\u7b2c\u4e00\u884c\u662f\u8ca8\u54c1\u6578\u91cf\uff0c\u63a5\u4e0b\u4f86\u6bcf\u884c\u5404\u6709\u5169\u7b46\u6578\u64da\uff0c\u7b2c\u4e00\u7b46\u4ee3\u8868\u5404\u9805\u8ca8\u7269\u7684\u9ad4\u7a4d\uff0c\u7b2c\u4e8c\u7b46\u4ee3\u8868\u5404\u9805\u8ca8\u7269\u7684\u5229\u6f64\u3002<\/td><td>\u8f38\u51fa\u6700\u5927\u7684\u5229\u6f64\uff0c\u4f8b\u5982\u8f38\u51fa\u4e00\u3001\u4e8c\u9805\uff1a\u7b2c\u4e00\u9805\u8ca8\u7269\u7684\u9ad4\u7a4d\u70ba 30\uff0c\u5229\u6f64\u70ba 60\uff0c\u7b2c\u4e8c\u9805\u8ca8\u7269\u7684\u9ad4\u7a4d\u70ba 20\uff0c\u5229\u6f64\u70ba 50\u3002<\/td><\/tr><tr><td>4<br>30 60<br>20 50<br>35 40<br>60 70<br>10<br>80 88<br>33 66<br>13 26<br>77 150<br>95 195<br>45 90<br>8 16<br>20 41<br>40 13<br>68 20<\/td><td>150<br>198<\/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 01 \u80cc\u5305\u7684\u6982\u5ff5\u4f86\u601d\u8003\u9019\u984c\u3002\u53ea\u662f\u8981\u5c07\u76ee\u524d\u91cd\u91cf\u7684\u50f9\u503c\u5b58\u5230 Map \u4e2d\u3002\u5982\u679c\u6709\u9047\u5230\u53ef\u4ee5\u6210\u5c0d\u7684\u6578\u5b57\uff0c\u5247\u8981\u5c07\u5169\u500b\u6578\u5b57\u7684 Map \u503c\u5b58\u653e\u5230\u5169\u7684\u6578\u5b57\u548c\u7684 Map \u503c\u4e2d\u3002<\/p>\n\n\n\n<p>\u6700\u5f8c\uff0c\u5f9e 100 \u5f80\u4e0b\u627e\u5230\u7b2c\u4e00\u500b\u5927\u65bc 0 \u7684 Map \u503c\u4e26\u8f38\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=b184\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge B184: \u88dd\u8ca8\u6ac3\u554f\u984c<\/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;unordered_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;\n    while (cin &gt;&gt; N) {\n        unordered_map&lt;int, int&gt;MAP;\n        vector&lt;pair&lt;int, int&gt;&gt; v;\n        for (int i = 0; i&lt;N; i++) {\n            int a, b;\n            cin &gt;&gt; a &gt;&gt; b;\n            v.push_back(make_pair(a, b));\n        }\n        for (int i = 0; i&lt;N; i++) {\n            const int weight = v[i].first;\n            for (int j = 100; j&gt;=weight; j--) {\n                if (MAP[j-weight] &gt;= 0) {\n                    MAP[j] = max(MAP[j], MAP[j-weight]+v[i].second);\n                }\n            }\n            MAP[weight] = max(MAP[weight], v[i].second);\n        }\n        for (int i = 100; i&gt;=100; i--) {\n            if (MAP[i] &gt;= 0) {\n                cout &lt;&lt; MAP[i] &lt;&lt; &quot;\\n&quot;;\n                break;\n            }\n        }\n    }\n}\n\n\/\/ZeroJudge B184\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u73fe\u5728\u4e00\u5171\u6709\u82e5\u5e72\u9805\u8ca8\u54c1\u53ef\u9078\u64c7\u904b\u8f09\uff0c\u6bcf\u4e00\u9805k\u90fd\u6709\u4e00\u500b\u5df2\u77e5\u7684\u9ad4\u7a4d v[k]\uff0c\u4ee5\u53ca\u8f09\u904b\u7684\u5229\u6f64 c[k]\uff0c\u4f46\u662f\u8ca8\u6ac3\u7684\u7e3d\u5bb9 [&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,9],"class_list":["post-1312","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-map","tag-pair","tag-20","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1312","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=1312"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1312\/revisions"}],"predecessor-version":[{"id":1313,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/1312\/revisions\/1313"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=1312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=1312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=1312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}