{"id":1314,"date":"2024-12-22T09:00:00","date_gmt":"2024-12-22T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1314"},"modified":"2024-12-13T03:40:28","modified_gmt":"2024-12-12T19:40:28","slug":"zerojudge-f440","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-f440\/","title":{"rendered":"ZeroJudge F440: SuperSale"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 10130 &#8211; SuperSale<\/h4>\n\n\n\n<p>\u6709\u9593\u5546\u5e97\u5171\u6709 N \u7a2e\u5546\u54c1\u6bcf\u7a2e\u5546\u54c1\u6709\u4e0d\u540c\u7684\u91cd\u91cf\u548c\u50f9\u503c\u4e14\u6bcf\u4eba\u6bcf\u7a2e\u6700\u591a\u53ea\u80fd\u62ff\u4e00\u500b\u3002<br>\u6c42\u51fa G \u500b\u4eba\u6700\u5927\u80fd\u62ff\u8d70\u591a\u5c11\u50f9\u503c\u7684\u5546\u54c1\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>\u7b2c\u4e00\u884c\u6709\u500b T \u4ee3\u8868\u6e2c\u8cc7\u6578\u76ee (1 \u2264 T \u2264 1000)<br>\u6bcf\u7b46\u6b21\u6e2c\u8cc7\u7b2c\u4e00\u884c\u6709\u500b\u6578\u5b57 N \u4ee3\u8868\u5546\u54c1\u6578\u76ee (1 \u2264 N \u2264 1000)\u3002<br>\u63a5\u4e0b\u4f86 N \u884c\u6709 P \u548c W \u5206\u5225\u4ee3\u8868\u5546\u54c1\u7684\u50f9\u503c\u548c\u91cd\u91cf\u3002<br>\u4e4b\u5f8c\u6709\u4e00\u884c G \u4ee3\u8868\u6709 G \u500b\u4eba (1 \u2264 G \u2264 100)\u3002<br>\u63a5\u4e0b\u4f86 G \u884c\u6709\u6bcf\u500b\u4eba\u7684\u8ca0\u91cd (\u7686\u5c0f\u65bc\u7b49\u65bc 30)\u3002<\/td><td>\u8f38\u51fa\u6700\u5927\u80fd\u62ff\u8d70\u591a\u5c11\u50f9\u503c\u7684\u5546\u54c1\u3002<\/td><\/tr><tr><td>2<br>3<br>72 17<br>44 23<br>31 24<br>1<br>26<br>6<br>64 26<br>85 22<br>52 4<br>99 18<br>39 13<br>54 9<br>4<br>23<br>20<br>20<br>26<\/td><td>72<br>514<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u5c0b\u627e\u6240\u6709\u4eba\u4e2d\u627f\u53d7\u91cd\u91cf\u7684\u6700\u5927\u503c\uff0c\u4e26\u4e14\u7528\u5176\u6578\u5b57\u505a 0 1 \u80cc\u5305\u7684\u554f\u984c\u4e26\u4e14\u751f\u6210 Map\uff0c\u5c0d\u6bcf\u500b\u4eba\u80fd\u627f\u53d7\u7684\u91cd\u91cf\u5f80\u4e0b\u627e\u5230\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=f440\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F440: SuperSale<\/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;\n#include &lt;vector&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int T;\n    cin &gt;&gt; T;\n    for (int i = 0; i &lt; T; i++) {\n        int N;\n        cin &gt;&gt; N;\n        int W[1000] = {};\n        int P[1000] = {};\n        for (int j = 0; j&lt;N; j++) {\n            cin &gt;&gt; P[j] &gt;&gt; W[j];\n        }\n        vector&lt;int&gt; people;\n        int G, maxx = -999;\n        cin &gt;&gt; G;\n        for (int j = 0; j&lt;G; j++) {\n            int tmp;\n            cin &gt;&gt; tmp;\n            people.push_back(tmp);\n            maxx = max(maxx, tmp);\n        }\n        map&lt;int, int&gt;ans;\n        for (int j = 0; j&lt;N; j++) {\n            int w = W[j] , p = P[j];\n            for (int k = maxx; k&gt;=w; k--) {\n                ans[k] = max(ans[k], ans[k-w]+p);\n            }\n            ans[w] = max(p, ans[w]);\n        }\n        int sum = 0;\n        for (int j = 0; j&lt;people.size(); j++) {\n            int maxx = -999;\n            for (int k = people[j]; k&gt;=0; k--) {\n                maxx = max(maxx, ans[k]);\n            }\n            sum += maxx;\n        }\n        cout &lt;&lt; sum &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge F440\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 10130 &#8211; SuperSale \u6709\u9593\u5546\u5e97\u5171\u6709 N \u7a2e\u5546\u54c1\u6bcf\u7a2e\u5546\u54c1\u6709\u4e0d\u540c\u7684\u91cd\u91cf\u548c\u50f9 [&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,9],"class_list":["post-1314","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-20","tag-8","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=1314"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1314\/revisions"}],"predecessor-version":[{"id":1315,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1314\/revisions\/1315"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=1314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=1314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=1314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}