{"id":2911,"date":"2022-03-13T12:56:11","date_gmt":"2022-03-13T04:56:11","guid":{"rendered":"http:\/\/139.9.1.231\/?p=2911"},"modified":"2022-03-13T12:56:12","modified_gmt":"2022-03-13T04:56:12","slug":"queqe","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2022\/03\/13\/queqe\/","title":{"rendered":"\u6570\u636e\u7ed3\u6784 &#8212; \u5355\u8c03\u961f\u5217"},"content":{"rendered":"\n<p>\u987e\u540d\u601d\u4e49\uff0c\u5355\u8c03\u961f\u5217\u7684\u91cd\u70b9\u5206\u4e3a &#8220;\u5355\u8c03&#8221; \u548c &#8220;\u961f\u5217&#8221;<\/p>\n\n\n\n<p>&#8220;\u5355\u8c03&#8221; \u6307\u7684\u662f\u5143\u7d20\u7684\u7684 &#8220;\u89c4\u5f8b&#8221;\u2014\u2014\u9012\u589e\uff08\u6216\u9012\u51cf\uff09<\/p>\n\n\n\n<p>&#8220;\u961f\u5217&#8221; \u6307\u7684\u662f\u5143\u7d20\u53ea\u80fd\u4ece\u961f\u5934\u548c\u961f\u5c3e\u8fdb\u884c\u64cd\u4f5c<\/p>\n\n\n\n<ul><li><strong>\u5355\u8c03\u9012\u589e\u961f\u5217<\/strong>\uff1a\u4fdd\u8bc1\u961f\u5217\u5934\u5143\u7d20\u4e00\u5b9a\u662f\u5f53\u524d\u961f\u5217\u7684\u6700\u5c0f\u503c\uff0c\u7528\u4e8e\u7ef4\u62a4\u533a\u95f4\u7684\u6700\u5c0f\u503c\u3002<\/li><li><strong>\u5355\u8c03\u9012\u51cf\u961f\u5217<\/strong>\uff1a\u4fdd\u8bc1\u961f\u5217\u5934\u5143\u7d20\u4e00\u5b9a\u662f\u5f53\u524d\u961f\u5217\u7684\u6700\u5927\u503c\uff0c\u7528\u4e8e\u7ef4\u62a4\u533a\u95f4\u7684\u6700\u5927\u503c\u3002<\/li><\/ul>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">1\u3001\u5bf9\u4e8e\u5355\u8c03\u9012\u589e\u961f\u5217\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u5143\u7d20\u5982\u679c\u5b83\u5927\u4e8e\u7b49\u4e8e\u961f\u5c3e\u5143\u7d20\uff0c \u90a3\u4e48\u76f4\u63a5\u628a\u5143\u7d20\u8fdb\u961f\uff0c \u5982\u679c\u8fd9\u4e2a\u5143\u7d20\u5c0f\u4e8e\u961f\u5c3e\u5143\u7d20\uff0c\u5219\u5c06\u961f\u5c3e\u5143\u7d20\u51fa\u961f\u5217\uff0c\u76f4\u5230\u6ee1\u8db3\u8fd9\u4e2a\u5143\u7d20\u5927\u4e8e\u7b49\u4e8e\u961f\u5c3e\u5143\u7d20\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">2\u3001\u5bf9\u4e8e\u5355\u8c03\u9012\u51cf\u961f\u5217\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u5143\u7d20\u5982\u679c\u5b83\u5c0f\u4e8e\u7b49\u4e8e\u961f\u5c3e\u5143\u7d20\uff0c \u90a3\u4e48\u76f4\u63a5\u628a\u5143\u7d20\u8fdb\u961f\uff0c \u5982\u679c\u8fd9\u4e2a\u5143\u7d20\u5927\u4e8e\u961f\u5c3e\u5143\u7d20\uff0c\u5219\u5c06\u961f\u5c3e\u5143\u7d20\u51fa\u961f\u5217\uff0c\u76f4\u5230\u6ee1\u8db3\u8fd9\u4e2a\u5143\u7d20\u5c0f\u4e8e\u7b49\u4e8e\u961f\u5c3e\u5143\u7d20\u3002<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\">3\u3001\u5224\u65ad\u961f\u5934\u5143\u7d20\u662f\u5426\u5728\u5f85\u6c42\u89e3\u7684\u533a\u95f4\u4e4b\u5185\uff0c\u5982\u679c\u4e0d\u5728\uff0c\u5c31\u5c06\u5176\u5220\u9664\u3002\uff08\u8fd9\u4e2a\u5f88\u597d\u7406\u89e3\u5440\uff0c\u56e0\u4e3a\u5355\u8c03\u961f\u5217\u7684\u961f\u5934\u5143\u7d20\u5c31\u662f\u5f85\u6c42\u89e3\u533a\u95f4\u7684\u6781\u503c\uff09<\/p>\n\n\n\n<p class=\"has-light-pink-background-color has-background\"> 4\u3001<span style=\"font-size: revert;\">\u7ecf\u8fc7\u4e0a\u9762\u4e24\u4e2a\u64cd\u4f5c\uff0c\u53d6\u51fa <\/span><strong style=\"font-size: revert;\">\u961f\u5217\u7684\u5934\u5143\u7d20<\/strong><span style=\"font-size: revert;\"> \uff0c\u5c31\u662f <\/span><strong style=\"font-size: revert;\">\u5f53\u524d\u533a\u95f4\u7684\u6781\u503c<\/strong><span style=\"font-size: revert;\"> \u3002<\/span> <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img loading=\"lazy\" width=\"852\" height=\"505\" src=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-50.png\" alt=\"\" class=\"wp-image-2915\" srcset=\"http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-50.png 852w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-50-300x178.png 300w, http:\/\/139.9.1.231\/wp-content\/uploads\/2022\/03\/image-50-768x455.png 768w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><\/figure>\n\n\n\n<p>\u53ef\u4ee5\u53d1\u73b0\u961f\u5217\u4e2d\u7684\u5143\u7d20\u90fd\u662f\u5355\u8c03\u9012\u51cf\u7684\uff08\u4e0d\u7136\u4e5f\u5c31\u4e0d\u53eb\u5355\u8c03\u9012\u51cf\u961f\u5217\u5566\uff09\uff0c\u540c\u65f6\u65e2\u6709\u5165\u961f\u5217\u7684\u64cd\u4f5c\u3001\u4e5f\u6709\u51fa\u961f\u5217\u7684\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u5b9e\u73b0\u5355\u8c03\u961f\u5217\uff0c\u4e3b\u8981\u5206\u4e3a\u4e09\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ul><li><strong><em>\u53bb\u5c3e\u64cd\u4f5c<\/em><\/strong> \uff1a<strong>\u961f\u5c3e\u5143\u7d20\u51fa\u961f\u5217<\/strong>\u3002\u5f53\u961f\u5217\u6709\u65b0\u5143\u7d20\u5f85\u5165\u961f\uff0c\u9700\u8981\u4ece\u961f\u5c3e\u5f00\u59cb\uff0c\u5220\u9664\u5f71\u54cd\u961f\u5217\u5355\u8c03\u6027\u7684\u5143\u7d20\uff0c\u7ef4\u62a4\u961f\u5217\u7684\u5355\u8c03\u6027\u3002(\u5220\u9664\u4e00\u4e2a\u961f\u5c3e\u5143\u7d20\u540e\uff0c\u5c31\u91cd\u65b0\u5224\u65ad\u65b0\u7684\u961f\u5c3e\u5143\u7d20)<\/li><\/ul>\n\n\n\n<p><strong>\u53bb\u5c3e\u64cd\u4f5c\u7ed3\u675f\u540e\uff0c\u5c06\u8be5\u65b0\u5143\u7d20\u5165\u961f\u5217\u3002<\/strong><\/p>\n\n\n\n<ul><li><strong><em>\u5220\u5934\u64cd\u4f5c<\/em><\/strong> \uff1a<strong>\u961f\u5934\u5143\u7d20\u51fa\u961f\u5217<\/strong>\u3002\u5224\u65ad\u961f\u5934\u5143\u7d20\u662f\u5426\u5728\u5f85\u6c42\u89e3\u7684\u533a\u95f4\u4e4b\u5185\uff0c\u5982\u679c\u4e0d\u5728\uff0c\u5c31\u5c06\u5176\u5220\u9664\u3002\uff08\u8fd9\u4e2a\u5f88\u597d\u7406\u89e3\u5440\uff0c\u56e0\u4e3a\u5355\u8c03\u961f\u5217\u7684\u961f\u5934\u5143\u7d20\u5c31\u662f\u5f85\u6c42\u89e3\u533a\u95f4\u7684\u6781\u503c\uff09<\/li><li><strong><em>\u53d6\u89e3\u64cd\u4f5c<\/em><\/strong> \uff1a\u7ecf\u8fc7\u4e0a\u9762\u4e24\u4e2a\u64cd\u4f5c\uff0c\u53d6\u51fa <strong>\u961f\u5217\u7684\u5934\u5143\u7d20<\/strong> \uff0c\u5c31\u662f <strong>\u5f53\u524d\u533a\u95f4\u7684\u6781\u503c<\/strong> \u3002<\/li><\/ul>\n\n\n\n<p>\u53c2\u8003\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;cstdio>\r\n#include &lt;cstdlib>\r\n#include &lt;cstring>\r\n#include &lt;iostream>\r\n#define maxn 1000100\r\nusing namespace std;\r\nint q&#91;maxn], a&#91;maxn];\r\nint n, k;\r\n\r\nvoid getmin() {  \/\/ \u5f97\u5230\u8fd9\u4e2a\u961f\u5217\u91cc\u7684\u6700\u5c0f\u503c\uff0c\u76f4\u63a5\u627e\u5230\u6700\u540e\u7684\u5c31\u884c\u4e86\r\n  int head = 0, tail = 0;\r\n  for (int i = 1; i &lt; k; i++) {\r\n    while (head &lt;= tail &amp;&amp; a&#91;q&#91;tail]] >= a&#91;i]) tail--;\r\n    q&#91;++tail] = i;\r\n  }\r\n  for (int i = k; i &lt;= n; i++) {\r\n    while (head &lt;= tail &amp;&amp; a&#91;q&#91;tail]] >= a&#91;i]) tail--;\r\n    q&#91;++tail] = i;\r\n    while (q&#91;head] &lt;= i - k) head++;\r\n    printf(\"%d \", a&#91;q&#91;head]]);\r\n  }\r\n}\r\n\r\nvoid getmax() {  \/\/ \u548c\u4e0a\u9762\u540c\u7406\r\n  int head = 0, tail = 0;\r\n  for (int i = 1; i &lt; k; i++) {\r\n    while (head &lt;= tail &amp;&amp; a&#91;q&#91;tail]] &lt;= a&#91;i]) tail--;\r\n    q&#91;++tail] = i;\r\n  }\r\n  for (int i = k; i &lt;= n; i++) {\r\n    while (head &lt;= tail &amp;&amp; a&#91;q&#91;tail]] &lt;= a&#91;i]) tail--;\r\n    q&#91;++tail] = i;\r\n    while (q&#91;head] &lt;= i - k) head++;\r\n    printf(\"%d \", a&#91;q&#91;head]]);\r\n  }\r\n}\r\n\r\nint main() {\r\n  scanf(\"%d%d\", &amp;n, &amp;k);\r\n  for (int i = 1; i &lt;= n; i++) scanf(\"%d\", &amp;a&#91;i]);\r\n  getmin();\r\n  printf(\"\\n\");\r\n  getmax();\r\n  printf(\"\\n\");\r\n  return 0;\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u987e\u540d\u601d\u4e49\uff0c\u5355\u8c03\u961f\u5217\u7684\u91cd\u70b9\u5206\u4e3a &#8220;\u5355\u8c03&#8221; \u548c &#8220;\u961f\u5217&#8221; &#038;#82 &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2022\/03\/13\/queqe\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u6570\u636e\u7ed3\u6784 &#8212; \u5355\u8c03\u961f\u5217<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,8],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2911"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=2911"}],"version-history":[{"count":11,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2911\/revisions"}],"predecessor-version":[{"id":2923,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/2911\/revisions\/2923"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=2911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=2911"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=2911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}