{"id":653,"date":"2024-07-08T09:00:00","date_gmt":"2024-07-08T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=653"},"modified":"2024-07-08T09:01:03","modified_gmt":"2024-07-08T01:01:03","slug":"zerojudge-d804","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-d804\/","title":{"rendered":"ZeroJudge D804: Lunch"},"content":{"rendered":"\n\n\n<p>\u67d0\u5929\u4e2d\u5348\u4f60\u5f88\u9913\u5f88\u9913\u5f88\u9913\u975e\u5e38\u9913\u9913\u5230\u4e0d\u884c\uff01<br>\u53ef\u662f\u4f60\u5df2\u7d93\u548c\u4eba\u7d04\u597d\u4e2d\u5348\u8981\u53bb\u7df4\u7fd2\u5beb\u7a0b\u5f0f\uff0c<br>\u56e0\u6b64\u4f60\u6c7a\u5b9a\u7528\u6700\u5feb\u7684\u901f\u5ea6\u5403\u98fd\u5f8c\u524d\u5f80\u96fb\u6559\uff0c<br>\u800c\u4e0d\u540c\u7684\u9910\u9ede\u53ef\u4ee5\u5e36\u4f86\u4e0d\u540c\u7a0b\u5ea6\u7684\u98fd\u8db3\u611f\uff0c<br>\u5047\u8a2d\u4f60<strong>\u5403\u6bcf\u4efd\u9910\u9ede\u7684\u90fd\u53ea\u6703\u82b1\u4e00\u55ae\u4f4d\u6642\u9593<\/strong>\uff0c<br>\u4e14<strong>\u540c\u6a23\u7684\u9910\u9ede\u4f60\u4e0d\u9858\u610f\u5348\u9910\u6642\u9593\u5167\u5403\u5169\u6b21<\/strong>\uff0c<br>\u8acb\u554f\u4f60\u81f3\u5c11\u8981\u82b1\u591a\u4e45\u7684\u6642\u9593\u624d\u80fd\u5403\u5230\u98fd\u5462\uff1f<\/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>\u7b2c\u4e00\u884c\u6709\u5169\u500b\u6b63\u6574\u6578 N \u548c M (N &lt;= 100000)<br>\u4ee3\u8868\u6709 N \u7a2e\u4e0d\u540c\u7684\u9910\u9ede\u548c\u9700\u8981 M \u55ae\u4f4d\u7684\u98fd\u8db3\u611f\u624d\u6703\u5403\u98fd\u3002<br>\u7b2c\u4e8c\u884c\u6709 N \u500b\u4e0d\u8d85\u904e1000\u7684\u6b63\u6574\u6578\uff0c\u5206\u5225\u4ee3\u8868\u7b2c 1 \u7a2e\u5230\u7b2c N \u7a2e\u9910\u9ede\u7684\u98fd\u8db3\u611f\u3002<\/td><td>\u4e00\u500b\u6578\u5b57\uff0c\u4ee3\u8868\u81f3\u5c11\u5403\u5e7e\u4efd\u624d\u6703\u98fd<br>\u5982\u679c\u4e0d\u7ba1\u600e\u6a23\u90fd\u5403\u4e0d\u98fd\u8acb\u8f38\u51fa\u300cOAQ&#8221;\u300d(\u4e0d\u542b\u96d9\u5f15\u865f)<\/td><\/tr><tr><td>5 10<br>8 5 3 2 1<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u5c07\u98df\u7269\u6536\u5230\u4e00\u500b\u4e00\u7dad\u9663\u5217\u4e2d\uff0c\u4e26\u4e14\u5c07\u5176\u6392\u5e8f\u3002\u5f9e\u6700\u53f3\u908a\u5403\u5230\u6700\u5de6\u908a\u4e26\u8f38\u51fa\u5403\u7684\u6b21\u6578\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d804\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D804: \u597d\u9913<\/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;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N, M;\n    cin &gt;&gt; N &gt;&gt; M;\n    vector&lt;int&gt;num;\n    for (int i = 0; i&lt;N; i++) {\n        int tmp;\n        cin &gt;&gt; tmp;\n        num.push_back(tmp);\n    }\n    sort(num.begin(), num.end());\n    int sum = 0, count = 0;\n    bool ok = false;\n    for (int i = N-1; i&gt;=0; i--) {\n        sum += num[i];\n        count++;\n        if (sum &gt;= M) {\n            cout &lt;&lt; count &lt;&lt; &quot;\\n&quot;;\n            ok = true;\n            break;\n        }\n    }\n    if (!ok) cout &lt;&lt; &quot;OAQ\\n&quot;;\n}\n\n\/\/ZeroJudge D804\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u67d0\u5929\u4e2d\u5348\u4f60\u5f88\u9913\u5f88\u9913\u5f88\u9913\u975e\u5e38\u9913\u9913\u5230\u4e0d\u884c\uff01\u53ef\u662f\u4f60\u5df2\u7d93\u548c\u4eba\u7d04\u597d\u4e2d\u5348\u8981\u53bb\u7df4\u7fd2\u5beb\u7a0b\u5f0f\uff0c\u56e0\u6b64\u4f60\u6c7a\u5b9a\u7528\u6700\u5feb\u7684\u901f\u5ea6\u5403\u98fd\u5f8c\u524d\u5f80\u96fb [&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":[20,8,34,19,9],"class_list":["post-653","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-20","tag-8","tag-34","tag-19","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/653","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=653"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/653\/revisions"}],"predecessor-version":[{"id":1057,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/653\/revisions\/1057"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}