{"id":245,"date":"2024-04-26T22:32:17","date_gmt":"2024-04-26T14:32:17","guid":{"rendered":"https:\/\/seanxd.com\/?p=245"},"modified":"2024-04-26T22:32:19","modified_gmt":"2024-04-26T14:32:19","slug":"zerojudge-e520","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-e520\/","title":{"rendered":"ZeroJudge E520: Rockabye Tobby"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 13190 &#8211; Rockabye Tobby<\/h4>\n\n\n\n<p class=\"\">&#8220;Rockabye baby, don&#8217;t you cry.&#8221;<br>Tobby\u975e\u5e38\u64c5\u9577\u50b3\u63a5\u7403\uff0c\u4ed6\u975e\u5e38\u559c\u6b61\u9019\u500b\u904a\u6232\uff0c\u6709\u4e00\u5929\u4ed6\u6c7a\u5b9a\u51fa\u53bb\u73a9\uff0c\u5373\u4f7f\u7576\u6642\u6b63\u5728\u4e0b\u96e8\u3002<br>\u4ed6\u73a9\u4e86\u5f88\u9577\u6642\u9593\uff0c\u9664\u4e86\u50b3\u63a5\u7403\u5f88\u591a\u6b21\u4e4b\u5916\uff0c\u9084\u9806\u4fbf\u751f\u4e86\u75c5\uff0c\u6709\u5920\u4e1f\u81c9\uff0c\u771f\u662f\u53ef\u60b2\u3002<br>\u9019\u5c31\u662f\u70ba\u4ec0\u9ebc\u73fe\u5728\u4ed6\u7684\u6bcd\u89aa (Big Doggie) \u5728\u7167\u9867\u4ed6\uff0c\u9664\u4e86\u5531\u90a3\u9996\u7f8e\u9e97\u7684\u6416\u7c43\u66f2 (Rockabye)\uff0c\u9084\u5728\u6307\u5b9a\u6642\u9593\u6e96\u5099\u597d\u85e5\u7d66\u4ed6\u5403\u3002<br>\u5728\u91ab\u751f\u7684\u91ab\u7642\u8655\u65b9\u4e2d\uff0c\u6307\u5b9a\u4e86\u85e5\u7269\u540d\u7a31\u4ee5\u53ca\u591a\u4e45\u670d\u7528\u4e00\u6b21\u3002<br>\u91ab\u751f\u544a\u8a34\u4ed6\uff0c\u5982\u679c\u4ed6\u6309\u7167\u91ab\u56d1\u670d\u85e5\uff0c\u670d\u7528 K \u500b\u85e5\u5f8c\u4ed6\u5c31\u6703\u597d\u8d77\u4f86\u3002<br>Tobby \u4e0d\u559c\u6b61\u751f\u75c5(\u5be6\u969b\u4e0a\u6c92\u4eba\u559c\u6b61)\uff0c\u6240\u4ee5\u4ed6\u5411\u6bcd\u89aa\u4fdd\u8b49\u4ed6\u6703\u6309\u6642\u5403\u85e5\u3002<br>\u9019\u5c31\u662f\u70ba\u4ec0\u9ebc\u4ed6\u73fe\u5728\u60f3\u77e5\u9053\uff0c\u4ed6<strong>\u5fc5\u9808\u670d\u7528\u7684\u524d K \u500b\u85e5\u7269\u662f\u54ea\u4e9b<\/strong>\uff0c\u624d\u80fd\u4f7f\u4ed6\u597d\u8d77\u4f86\uff0c\u4e26\u4e14\u80fd\u5728\u4e0b\u96e8\u5929\u7e7c\u7e8c\u53bb\u50b3\u63a5\u7403\u3002<br>\u4f60\u80fd\u5e6b\u4ed6\u55ce\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>\u8f38\u5165\u5f9e\u5305\u542b\u4e00\u500b\u6574\u6578 T (1 \u2264 T \u2264 15)\uff0c\u4ee3\u8868 Case \u7684\u6578\u91cf\u3002<br>\u5c0d\u65bc\u6bcf\u500b Case \u5305\u542b\u5169\u500b\u6574\u6578 N (1 \u2264 N \u2264 3\uff0a10<sup>3<\/sup>)\u548c K (1 \u2264 K \u2264 10<sup>4<\/sup>)<br>N \u4ee3\u8868\u91ab\u751f\u767c\u9001\u7684\u85e5\u7269\u6578\u91cf\uff0cK \u4ee3\u8868 Tobby \u5fc5\u9808\u670d\u7528\u7684\u6700\u5c11\u85e5\u7269\u6578\u91cf\u3002<br>\u63a5\u4e0b\u4f86\u7684 N \u884c\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u500b\u5b57\u4e32 M\uff0c\u4e00\u500b\u6574\u6578 F (1 \u2264 F \u2264 3\uff0a10<sup>3<\/sup>)\u3002<br>M \u4ee3\u8868\u85e5\u7269\u540d\u7a31 (1 \u2264 M \u9577\u5ea6 \u2264 15)\uff0cF \u4ee3\u8868\u670d\u7528\u983b\u7387\u3002<br>\u85e5\u7269\u662f\u6839\u64da\u5176\u512a\u5148\u7d1a\u5217\u51fa\u7684\uff0c\u5373<strong>\u7b2c\u4e00\u7a2e\u662f\u6700\u91cd\u8981\u7684\u85e5\u7269\uff0c\u6700\u5f8c\u4e00\u7a2e\u662f\u6700\u4e0d\u91cd\u8981\u7684\u85e5\u7269<\/strong>\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u500b Case\uff0c\u8f38\u51fa\u5fc5\u9808\u6709k\u884c\uff0c\u6bcf\u884c\u5f62\u5f0f\u70ba\u300ct m\u300d\u3002<br>\u300ct m\u300d\u8868\u793a\u5728 t \u6642\u523b Tobby \u5fc5\u9808\u670d\u7528\u85e5\u7269 m\u3002<br>\u5982\u679c\u5fc5\u9808\u5728\u540c\u4e00\u6642\u9593 t \u670d\u7528\u5169\u7a2e\u6216\u5169\u7a2e\u4ee5\u4e0a\u85e5\u7269\uff0c\u5247<strong>\u61c9\u6839\u64da\u5176\u512a\u5148\u7d1a\u9032\u884c\u8f38\u51fa<\/strong>\u3002<\/td><\/tr><tr><td>1<br>2  5<br>Acetaminophen  20<br>Loratadine  30<\/td><td>20  Acetaminophen<br>30  Loratadine<br>40  Acetaminophen<br>60  Acetaminophen<br>60  Loratadine<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge E520 \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 <strong>Vector<\/strong> \u548c <strong>Pair<\/strong> \u5c07<strong>\u85e5\u7269\u7684\u540d\u7a31\u53ca\u670d\u7528\u983b\u7387<\/strong>\u5b58\u8d77\u4f86\uff0c\u4e26\u7528 <strong>While\u8ff4\u5708 <\/strong>\u4f86\u5224\u65b7\u76ee\u524d\u7684\u6642\u9593\u662f\u5426\u6709\u9700\u8981\u670d\u7528\u7684\u85e5\u7269 <strong>(\u53ef\u4ee5\u88ab\u670d\u7528\u983b\u7387\u6574\u9664)<\/strong>\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u53ea\u8981\u670d\u7528\u4e86\u4e00\u7a2e\u85e5\u7269\u5c31\u9700\u8981\u5224\u65b7\u76ee\u524d\u670d\u7528\u7684\u85e5\u7269\u6578\u91cf\u662f\u5426\u6709\u7b49\u65bc K\uff0c\u5982\u679c\u6709\u7684\u8a71\u5c31\u9700\u8981\u5c07\u8ff4\u5708 Break \u6389\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=e520\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge E520: Rockabye Tobby<\/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\npair&lt;string, int&gt; rtn (string name, int time)\n{\n    pair&lt;string, int&gt;tmp;\n    tmp.first = name;\n    tmp.second = time;\n    return tmp;\n}\n\nint main() {\n    int N;\n    cin &gt;&gt; N;\n    for (int i = 0; i&lt;N; i++)\n    {\n        int med, K;\n        cin &gt;&gt; med &gt;&gt; K;\n        vector&lt;pair&lt;string, int&gt;&gt;v;\n        for (int j = 0; j&lt;med; j++)\n        {\n            string name;\n            int time;\n            cin &gt;&gt; name &gt;&gt; time;\n            v.push_back(rtn(name, time));\n        }\n        int count = 0, j = 1;\n        while (count &lt; K)\n        {\n            for (auto it:v)\n            {\n                if (j % it.second == 0)\n                {\n                    cout &lt;&lt; j &lt;&lt; &quot; &quot; &lt;&lt; it.first &lt;&lt; &quot;\\n&quot;;\n                    count++;\n                    if (count &gt;= K) break;\n                }\n            }\n            j++;\n        }\n    }\n}\n\n\/\/ZeroJudge E520\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 13190 &#8211; Rockabye Tobby &#8220;Rockabye bab [&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":[23,20,8,11,13,9],"class_list":["post-245","post","type-post","status-publish","format-standard","hentry","category-uva","tag-pair","tag-20","tag-8","tag-11","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/245","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=245"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/245\/revisions\/247"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}