{"id":170,"date":"2026-03-26T22:06:25","date_gmt":"2026-03-26T14:06:25","guid":{"rendered":"https:\/\/www.heroking2000.com\/?p=170"},"modified":"2026-03-26T22:06:25","modified_gmt":"2026-03-26T14:06:25","slug":"%e6%b4%9b%e8%b0%b7p2920-usaco08nov-time-management-s","status":"publish","type":"post","link":"https:\/\/www.heroking2000.com\/?p=170","title":{"rendered":"\u6d1b\u8c37P2920 [USACO08NOV] Time Management S"},"content":{"rendered":"\n<p>\u4f5c\u4e3a\u4e00\u540d\u5fd9\u788c\u7684\u5546\u4eba\uff0c\u7ea6\u7ff0\u77e5\u9053\u5fc5\u987b\u9ad8\u6548\u5730\u5b89\u6392\u4ed6\u7684\u65f6\u95f4\u3002\u4ed6\u6709&nbsp;<em>N<\/em>(1\u2264<em>N<\/em>\u22641000)&nbsp;\u4e2a\u5de5\u4f5c\u8981\u505a\uff0c\u6bd4\u5982\u7ed9\u5976\u725b\u6324\u5976\uff0c\u6e05\u6d17\u725b\u68da\uff0c\u4fee\u7406\u6805\u680f\u4e4b\u7c7b\u7684\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u9ad8\u6548\uff0c\u7ea6\u7ff0\u5217\u51fa\u4e86\u6240\u6709\u5de5\u4f5c\u7684\u6e05\u5355\u3002\u7b2c&nbsp;<em>i<\/em>(1\u2264<em>i<\/em>\u2264<em>N<\/em>)&nbsp;\u4e2a\u5de5\u4f5c\u9700\u8981&nbsp;<em>T<\/em><em>i<\/em>\u200b(1\u2264<em>T<\/em><em>i<\/em>\u200b\u22641000)&nbsp;\u5355\u4f4d\u7684\u65f6\u95f4\u6765\u5b8c\u6210\uff0c\u800c\u4e14\u5fc5\u987b\u5728&nbsp;1\u2264<em>S<\/em><em>i<\/em>\u200b\u2264106&nbsp;\u6216\u4e4b\u524d\u5b8c\u6210\u3002\u73b0\u5728\u662f&nbsp;0&nbsp;\u65f6\u523b\u3002\u7ea6\u7ff0\u505a\u4e00\u4efd\u5de5\u4f5c\u5fc5\u987b\u76f4\u5230\u505a\u5b8c\u624d\u80fd\u505c\u6b62\u3002<\/p>\n\n\n\n<p>\u6240\u6709\u7684\u5546\u4eba\u90fd\u559c\u6b22\u7761\u61d2\u89c9\u3002\u8bf7\u5e2e\u7ea6\u7ff0\u8ba1\u7b97\u4ed6\u6700\u8fdf\u4ec0\u4e48\u65f6\u5019\u5f00\u59cb\u5de5\u4f5c\uff0c\u53ef\u4ee5\u8ba9\u6240\u6709\u5de5\u4f5c\u6309\u65f6\u5b8c\u6210\u3002\uff08\u5982\u679c\u59cb\u7ec8\u65e0\u6cd5\u5b8c\u6210\u5168\u90e8\u4efb\u52a1\uff0c\u8f93\u51fa&nbsp;<code>-1<\/code>\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h2>\n\n\n\n<p>\u7b2c\u4e00\u884c\uff0c\u4e00\u4e2a\u6574\u6570&nbsp;<em>N<\/em><\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765&nbsp;<em>N<\/em>&nbsp;\u884c\uff0c\u6bcf\u884c&nbsp;2&nbsp;\u4e2a\u6709\u7a7a\u683c\u5206\u9694\u7684\u6574\u6570&nbsp;<em>T<\/em><em>i<\/em>\u200b,<em>S<\/em><em>i<\/em>\u200b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h2>\n\n\n\n<p>\u4e00\u884c\uff0c\u4e00\u4e2a\u6574\u6570\uff0c\u8868\u793a\u7ea6\u7ff0\u53ef\u4ee5\u5f00\u59cb\u5de5\u4f5c\u7684\u6700\u665a\u65f6\u95f4\uff0c\u5982\u679c\u7ea6\u7ff0\u65e0\u6cd5\u5b8c\u6210\u6240\u6709\u5de5\u4f5c\uff0c\u5219\u4e3a&nbsp;<code>-1<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f93\u5165\u8f93\u51fa\u6837\u4f8b<\/h2>\n\n\n\n<p><strong>\u8f93\u5165 #1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">4 \n3 5 \n8 14 \n5 20 \n1 16 \n<\/pre>\n\n\n\n<p><strong>\u8f93\u51fa #1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">2 \n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bf4\u660e\/\u63d0\u793a<\/h2>\n\n\n\n<p><strong>\u3010\u6837\u4f8b\u89e3\u91ca\u3011<\/strong><\/p>\n\n\n\n<p>\u7ea6\u7ff0\u6709&nbsp;4&nbsp;\u4e2a\u5de5\u4f5c\u8981\u505a\uff0c\u5206\u522b\u9700\u8981&nbsp;3\u30018\u30015&nbsp;\u548c&nbsp;1&nbsp;\u4e2a\u65f6\u95f4\u5355\u4f4d\uff0c\u5e76\u4e14\u5fc5\u987b\u5206\u522b\u5728\u65f6\u95f4&nbsp;5\u300114\u300120&nbsp;\u548c&nbsp;16&nbsp;\u4e4b\u524d\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u7ea6\u7ff0\u5fc5\u987b\u5728\u65f6\u95f4&nbsp;2&nbsp;\u5f00\u59cb\u7b2c\u4e00\u4e2a\u4f5c\u4e1a\u3002\u7136\u540e\u4ed6\u53ef\u4ee5\u6309\u6b64\u987a\u5e8f\u5b8c\u6210\u7b2c\u4e8c\u3001\u7b2c\u56db\u548c\u7b2c\u4e09\u9879\u5de5\u4f5c\uff0c\u4ee5\u6309\u65f6\u5b8c\u6210\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u3010\u4ee3\u7801\u793a\u4f8b\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h>\nusing namespace std;\nconst int MAXN = 1e3 + 5;\nint n;\n\nstruct task {\n\tint t;\n\tint s;\n} T&#91;MAXN];\n\nbool cmp(task a, task b) {\n\treturn a.s &lt; b.s;\n}\n\nbool check(int x) {\n\tint sum = x;\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\tsum += T&#91;i].t;\n\t\tif (sum > T&#91;i].s) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nint main() {\n\tcin >> n;\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\tcin >> T&#91;i].t >> T&#91;i].s;\n\t}\n\tsort(T + 1, T + n + 1, cmp);\n\tint l = 0, r = 1e6, ans = -1;\n\twhile (l &lt;= r) {\n\t\tint mid = l + (r - l) \/ 2;\n\t\tif (check(mid)) {\n\t\t\tl = mid + 1;\n\t\t\tans = mid;\n\t\t} else {\n\t\t\tr = mid - 1;\n\t\t}\n\t}\n\tcout &lt;&lt; ans;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u4e00\u540d\u5fd9\u788c\u7684\u5546\u4eba\uff0c\u7ea6\u7ff0\u77e5\u9053\u5fc5\u987b\u9ad8\u6548\u5730\u5b89\u6392\u4ed6\u7684\u65f6\u95f4\u3002\u4ed6\u6709&nbsp;N(1\u2264N\u22641000)&nbsp;\u4e2a\u5de5\u4f5c\u8981 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[24,25],"class_list":["post-170","post","type-post","status-publish","format-standard","hentry","category-oi","tag-24","tag-25"],"_links":{"self":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=170"}],"version-history":[{"count":1,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/170\/revisions\/171"}],"wp:attachment":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}