{"id":151,"date":"2026-03-18T23:12:14","date_gmt":"2026-03-18T15:12:14","guid":{"rendered":"https:\/\/blog.heroking2000.com\/?p=151"},"modified":"2026-03-18T23:14:40","modified_gmt":"2026-03-18T15:14:40","slug":"%e7%ac%ack1%e5%a4%a7%e7%9a%84%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.heroking2000.com\/?p=151","title":{"rendered":"\u7b2ck+1\u5927\u7684\u6570"},"content":{"rendered":"\n<p>\u9898\u76ee\u63cf\u8ff0<\/p>\n\n\n\n<p>\u7ed9\u5b9a\u957f\u5ea6\u4e3aN\u7684\u6570\u5217A = (A<sub>1<\/sub>, A<sub>2<\/sub>, \u2026, A<sub>N<\/sub>)\uff0c \u548c \u6574\u6570K = 0, 1, 2, \u2026, N\u22121\uff0c\u8bf7\u95ee A \u4e2d\u6709\u591a\u5c11\u4e2aA<sub>i<\/sub>&nbsp;\uff081 &lt;= i &lt;= n) \u6070\u597d\u5305\u542b k \u4e2a\u5927\u4e8e\u5b83\u7684\u4e0d\u540c\u6b63\u6574\u6570\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u5171\u4e24\u884c\uff0c<br>\u7b2c\u4e00\u884c\uff0c\u4e00\u4e2a\u6b63\u6574\u6570 N\uff0c\u8868\u793a\u8f93\u5165\u6570\u7684\u4e2a\u6570\uff1b<br>\u7b2c\u4e8c\u884c\uff0cN\u4e2a\u6574\u6570 A<sub>i<\/sub>&nbsp;\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u51fa\u683c\u5f0f\u3011<\/p>\n\n\n\n<p>\u5171N\u884c\uff0c\u6bcf\u884c\u4e00\u4e2a\u6574\u6570\uff0c\u5206\u522b\u8868\u793aK = 0, 1, 2, \u2026, N\u22121\u65f6\u7684\u7b54\u6848\u3002<\/p>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#1\u3011<\/p>\n\n\n\n<p>\u8f93\u5165#1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">6\n2 7 1 8 2 8\n<\/pre>\n\n\n\n<p>\u8f93\u51fa#1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">2\n1\n2\n1\n0\n0\n<\/pre>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#2\u3011<\/p>\n\n\n\n<p>\u8f93\u5165#2<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1\n1\n<\/pre>\n\n\n\n<p>\u8f93\u51fa#2<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1\n<\/pre>\n\n\n\n<p>\u3010\u8f93\u5165\u8f93\u51fa\u6837\u4f8b#3\u3011<\/p>\n\n\n\n<p>\u8f93\u5165#3<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">10\n979861204 57882493 979861204 447672230 644706927 710511029 763027379 710511029 447672230 136397527\n<\/pre>\n\n\n\n<p>\u8f93\u51fa#3<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">2\n1\n2\n1\n2\n1\n1\n0\n0\n0\n<\/pre>\n\n\n\n<p>\u3010\u8bf4\u660e\u63d0\u793a\u3011<\/p>\n\n\n\n<p>\u5bf9\u4e8e\u6837\u4f8b1\u7684\u8bf4\u660e\uff1a<br>\u5f53 K \u4e3a 2 \u65f6.<br>A<sub>1<\/sub>&nbsp;= 2\uff0cA\u5305\u542b\u4e86 2 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a7\u30018\uff1b<br>A<sub>2<\/sub>&nbsp;= 7\uff0cA\u5305\u542b\u4e86 1 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a8\uff1b<br>A<sub>3<\/sub>&nbsp;= 1\uff0cA\u5305\u542b\u4e86 3 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a2\u30017\u30018\uff1b<br>A<sub>4<\/sub>&nbsp;= 8\uff0cA\u5305\u542b\u4e86 0 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a\u65e0\uff1b<br>A<sub>5<\/sub>&nbsp;= 2\uff0cA\u5305\u542b\u4e86 2 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a7\u30018\uff1b<br>A<sub>6<\/sub>&nbsp;= 8\uff0cA\u5305\u542b\u4e86 0 \u4e2a\u4e0d\u540c\u7684\u5927\u4e8e\u5b83\u7684\u6b63\u6574\u6570\uff1a\u65e0\uff1b<br>\u200b<\/p>\n\n\n\n<p>\u3010\u6570\u636e\u8303\u56f4\u3011<\/p>\n\n\n\n<p>1 \u2264 N \u2264 2 \u00d7 10<sup>5<\/sup><\/p>\n\n\n\n<p>1 \u2264 A<sub>i<\/sub>&nbsp;\u2264 10<sup>9<\/sup><\/p>\n\n\n\n<p>\u3010\u4ee3\u7801\u6837\u4f8b\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\nconst int MAXN = 2 * 1e5 + 5;\nint n;\nint a&#91;MAXN];\nint b&#91;MAXN];\nint k&#91;MAXN];\n\nint main() {\n\tcin &gt;&gt; n;\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\tcin &gt;&gt; a&#91;i];\n\t}\n\tsort(a + 1, a + n + 1); \/\/\u6392\u5e8f\n\t\/\/\u53bb\u91cd\n\tint j = 1;\n\tb&#91;j] = a&#91;1];\n\tfor (int i = 2; i &lt;= n; i++) {\n\t\tif (a&#91;i] != b&#91;j]) {\n\t\t\tj++;\n\t\t\tb&#91;j] = a&#91;i];\n\t\t}\n\t}\n\tfor (int i = 1; i &lt;= n; i++) {\n\t\tint x = upper_bound(b + 1, b + j + 1, a&#91;i]) - b;\n\t\tk&#91;j - x + 1]++;\n\t}\n\tfor (int i = 0; i &lt; n; i++) {\n\t\tcout &lt;&lt; k&#91;i] &lt;&lt; endl;\n\t}\n\n\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 \u7ed9\u5b9a\u957f\u5ea6\u4e3aN\u7684\u6570\u5217A = (A1, A2, \u2026, AN)\uff0c \u548c \u6574\u6570K = 0, 1, 2, \u2026,  [&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,31],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-oi","tag-24","tag-25","tag-31"],"_links":{"self":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/151","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=151"}],"version-history":[{"count":2,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.heroking2000.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}