{"id":1220,"date":"2023-05-05T19:13:40","date_gmt":"2023-05-05T11:13:40","guid":{"rendered":"https:\/\/white-night.club\/?p=1220"},"modified":"2023-11-09T11:07:55","modified_gmt":"2023-11-09T03:07:55","slug":"ad11","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/05\/05\/ad11\/","title":{"rendered":"2432.\u00a0\u5904\u7406\u7528\u65f6\u6700\u957f\u7684\u90a3\u4e2a\u4efb\u52a1\u7684\u5458\u5de5"},"content":{"rendered":"\n<p>\u5171\u6709&nbsp;<code>n<\/code>&nbsp;\u4f4d\u5458\u5de5\uff0c\u6bcf\u4f4d\u5458\u5de5\u90fd\u6709\u4e00\u4e2a\u4ece&nbsp;<code>0<\/code>&nbsp;\u5230&nbsp;<code>n - 1<\/code>&nbsp;\u7684\u552f\u4e00 id \u3002<\/p>\n\n\n\n<p>\u7ed9\u4f60\u4e00\u4e2a\u4e8c\u7ef4\u6574\u6570\u6570\u7ec4&nbsp;<code>logs<\/code>&nbsp;\uff0c\u5176\u4e2d&nbsp;<code>logs[i] = [id<sub>i<\/sub>, leaveTime<sub>i<\/sub>]<\/code>&nbsp;\uff1a<\/p>\n\n\n\n<ul>\n<li><code>id<sub>i<\/sub><\/code>&nbsp;\u662f\u5904\u7406\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u4efb\u52a1\u7684\u5458\u5de5\u7684 id \uff0c\u4e14<\/li>\n\n\n\n<li><code>leaveTime<sub>i<\/sub><\/code>&nbsp;\u662f\u5458\u5de5\u5b8c\u6210\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u4efb\u52a1\u7684\u65f6\u523b\u3002\u6240\u6709&nbsp;<code>leaveTime<sub>i<\/sub><\/code>&nbsp;\u7684\u503c\u90fd\u662f&nbsp;<strong>\u552f\u4e00<\/strong>&nbsp;\u7684\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6ce8\u610f\uff0c\u7b2c&nbsp;<code>i<\/code>&nbsp;\u4e2a\u4efb\u52a1\u5728\u7b2c&nbsp;<code>(i - 1)<\/code>&nbsp;\u4e2a\u4efb\u52a1\u7ed3\u675f\u540e\u7acb\u5373\u5f00\u59cb\uff0c\u4e14\u7b2c&nbsp;<code>0<\/code>&nbsp;\u4e2a\u4efb\u52a1\u4ece\u65f6\u523b&nbsp;<code>0<\/code>&nbsp;\u5f00\u59cb\u3002<\/p>\n\n\n\n<p>\u8fd4\u56de\u5904\u7406\u7528\u65f6\u6700\u957f\u7684\u90a3\u4e2a\u4efb\u52a1\u7684\u5458\u5de5\u7684 id \u3002\u5982\u679c\u5b58\u5728\u4e24\u4e2a\u6216\u591a\u4e2a\u5458\u5de5\u540c\u65f6\u6ee1\u8db3\uff0c\u5219\u8fd4\u56de\u51e0\u4eba\u4e2d&nbsp;<strong>\u6700\u5c0f<\/strong>&nbsp;\u7684 id \u3002<\/p>\n\n\n\n<p><strong>\u793a\u4f8b 1\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 10, logs = [[0,3],[2,5],[0,9],[1,15]]\n<strong>\u8f93\u51fa\uff1a<\/strong>1\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u4efb\u52a1 0 \u4e8e\u65f6\u523b 0 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 3 \u7ed3\u675f\uff0c\u5171\u8ba1 3 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 1 \u4e8e\u65f6\u523b 3 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 5 \u7ed3\u675f\uff0c\u5171\u8ba1 2 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 2 \u4e8e\u65f6\u523b 5 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 9 \u7ed3\u675f\uff0c\u5171\u8ba1 4 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 3 \u4e8e\u65f6\u523b 9 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 15 \u7ed3\u675f\uff0c\u5171\u8ba1 6 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u65f6\u95f4\u6700\u957f\u7684\u4efb\u52a1\u662f\u4efb\u52a1 3 \uff0c\u800c id \u4e3a 1 \u7684\u5458\u5de5\u662f\u5904\u7406\u6b64\u4efb\u52a1\u7684\u5458\u5de5\uff0c\u6240\u4ee5\u8fd4\u56de 1 \u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 2\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 26, logs = [[1,1],[3,7],[2,12],[7,17]]\n<strong>\u8f93\u51fa\uff1a<\/strong>3\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u4efb\u52a1 0 \u4e8e\u65f6\u523b 0 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 1 \u7ed3\u675f\uff0c\u5171\u8ba1 1 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 1 \u4e8e\u65f6\u523b 1 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 7 \u7ed3\u675f\uff0c\u5171\u8ba1 6 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 2 \u4e8e\u65f6\u523b 7 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 12 \u7ed3\u675f\uff0c\u5171\u8ba1 5 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 3 \u4e8e\u65f6\u523b 12 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 17 \u7ed3\u675f\uff0c\u5171\u8ba1 5 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u65f6\u95f4\u6700\u957f\u7684\u4efb\u52a1\u662f\u4efb\u52a1 1 \uff0c\u800c id \u4e3a 3 \u7684\u5458\u5de5\u662f\u5904\u7406\u6b64\u4efb\u52a1\u7684\u5458\u5de5\uff0c\u6240\u4ee5\u8fd4\u56de 3 \u3002\n<\/pre>\n\n\n\n<p><strong>\u793a\u4f8b 3\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>\u8f93\u5165\uff1a<\/strong>n = 2, logs = [[0,10],[1,20]]\n<strong>\u8f93\u51fa\uff1a<\/strong>0\n<strong>\u89e3\u91ca\uff1a<\/strong>\n\u4efb\u52a1 0 \u4e8e\u65f6\u523b 0 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 10 \u7ed3\u675f\uff0c\u5171\u8ba1 10 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u4efb\u52a1 1 \u4e8e\u65f6\u523b 10 \u5f00\u59cb\uff0c\u4e14\u5728\u65f6\u523b 20 \u7ed3\u675f\uff0c\u5171\u8ba1 10 \u4e2a\u5355\u4f4d\u65f6\u95f4\u3002\n\u65f6\u95f4\u6700\u957f\u7684\u4efb\u52a1\u662f\u4efb\u52a1 0 \u548c 1 \uff0c\u5904\u7406\u8fd9\u4e24\u4e2a\u4efb\u52a1\u7684\u5458\u5de5\u7684 id \u5206\u522b\u662f 0 \u548c 1 \uff0c\u6240\u4ee5\u8fd4\u56de\u6700\u5c0f\u7684 0 \u3002\n<\/pre>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><code>2 &lt;= n &lt;= 500<\/code><\/li>\n\n\n\n<li><code>1 &lt;= logs.length &lt;= 500<\/code><\/li>\n\n\n\n<li><code>logs[i].length == 2<\/code><\/li>\n\n\n\n<li><code>0 &lt;= id<sub>i<\/sub> &lt;= n - 1<\/code><\/li>\n\n\n\n<li><code>1 &lt;= leaveTime<sub>i<\/sub> &lt;= 500<\/code><\/li>\n\n\n\n<li><code>id<sub>i<\/sub> != id<sub>i + 1<\/sub><\/code><\/li>\n\n\n\n<li><code>leaveTime<sub>i<\/sub><\/code>&nbsp;\u6309\u4e25\u683c\u9012\u589e\u987a\u5e8f\u6392\u5217<\/li>\n<\/ul>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u521d\u59cb\u4ee3\u7801<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\npublic:\n    int hardestWorker(int n, vector&lt;vector&lt;int>>&amp; logs) {\n\n    };\n};<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>vector\u7528\u6cd5<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u9898\u4e0d\u96be\uff0c\u4e3b\u8981\u662f\u719f\u6089\u4e0b\u4e8c\u7ef4vector\u7684\u7528\u6cd5\u3002<\/p>\n\n\n\n<p>\u904d\u5386vector\u7136\u540e\u6839\u636e\u5927\u5c0f\u6bd4\u8f83\u53bb\u7ef4\u62a4id\u5373\u53ef\u3002\u8fd9\u91cc\u4e3a\u4e86\u51cf\u5c11\u51cf\u6cd5\u6b21\u6570\u7528\u53d8\u91cftmp\u4ee3\u66ff\u51cf\u6cd5\u7ed3\u679c\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong>\u5b8c\u6574\u4ee3\u7801<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Solution {\r\npublic:\r\n    int hardestWorker(int n, vector&lt;vector&lt;int>>&amp; logs) {\r\n        int len=logs.size()-1;\r\n        int id=500;\r\n        int max=0,curtime=0;\r\n        for(int i=0;i&lt;=len;i++)\r\n        {\r\n            int tmp=logs&#91;i]&#91;1]-curtime;\r\n            if(max&lt;tmp)\r\n            {\r\n                max=logs&#91;i]&#91;1]-curtime;\r\n                id=logs&#91;i]&#91;0];\r\n            }else if(max==tmp&amp;&amp;logs&#91;i]&#91;0]&lt;id)\r\n                    id=logs&#91;i]&#91;0];\r\n            curtime=logs&#91;i]&#91;1];\r\n        }\r\n        return id;\r\n    };\r\n};<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>LeetCode\u9898\u76ee\uff1a\u4e8c\u7ef4vector<\/p>\n","protected":false},"author":1,"featured_media":2827,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[42,25],"tags":[38],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1220"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=1220"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1220\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/2827"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}