{"id":76385,"date":"2026-02-22T12:17:08","date_gmt":"2026-02-22T04:17:08","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76385.html"},"modified":"2026-02-22T12:17:08","modified_gmt":"2026-02-22T04:17:08","slug":"%e7%ae%80%e5%8d%95%e5%88%a9%e7%94%a8%e6%a0%91%e7%8a%b6%e6%95%b0%e7%bb%84%e4%bc%98%e5%8c%96%e5%ae%9e%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76385.html","title":{"rendered":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b"},"content":{"rendered":"<h2><\/h2>\n<h2>\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b&#xff1a;\u4ece O(n\u00b2) \u5230 O(n log n)<\/h2>\n<p>\u4f8b\u9898\u94fe\u63a5:\u5de6\u4fa7\u4e25\u683c\u5c0f\u4e8e\u8ba1\u6570_\u725b\u5ba2\u9898\u9738_\u725b\u5ba2\u7f51<\/p>\n<h3>\u95ee\u9898\u7b80\u8ff0:<\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n \u7684\u6570\u7ec4 a&#xff0c;\u5bf9\u4e8e\u6bcf\u4e2a\u4f4d\u7f6e i&#xff0c;\u6c42\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6570\u6bd4 a[i] \u5c0f\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>\u8f93\u5165&#xff1a;a &#061; [5, 2, 4, 1, 3]<br \/>\n\u8f93\u51fa&#xff1a;0 0 1 0 2<br \/>\n\u89e3\u91ca&#xff1a;<br \/>\n&#8211; i&#061;1, a[1]&#061;5, \u524d\u9762\u65e0\u6570 \u2192 0<br \/>\n&#8211; i&#061;2, a[2]&#061;2, \u524d\u9762[5], \u65e0\u6bd42\u5c0f\u7684 \u2192 0<br \/>\n&#8211; i&#061;3, a[3]&#061;4, \u524d\u9762[5,2], \u6bd44\u5c0f\u7684\u6709[2] \u2192 1<br \/>\n&#8211; i&#061;4, a[4]&#061;1, \u524d\u9762[5,2,4], \u65e0\u6bd41\u5c0f\u7684 \u2192 0<br \/>\n&#8211; i&#061;5, a[5]&#061;3, \u524d\u9762[5,2,4,1], \u6bd43\u5c0f\u7684\u6709[2,1] \u2192 2 <\/p>\n<hr \/>\n<h3>\u65b9\u6cd5\u4e00&#xff1a;\u66b4\u529b\u89e3\u6cd5 O(n\u00b2)<\/h3>\n<h4>\u6838\u5fc3\u601d\u8def<\/h4>\n<p>\u5bf9\u4e8e\u6bcf\u4e2a\u4f4d\u7f6e&#xff0c;\u904d\u5386\u524d\u9762\u6240\u6709\u5143\u7d20&#xff0c;\u9010\u4e2a\u6bd4\u8f83\u7edf\u8ba1\u3002<\/p>\n<h4>\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>#include &lt;bits\/stdc&#043;&#043;.h&gt;<br \/>\nusing namespace std;<br \/>\ntypedef long long ll;<\/p>\n<p>int main() {<br \/>\n    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);<\/p>\n<p>    int n;<br \/>\n    cin &gt;&gt; n;<br \/>\n    vector&lt;int&gt; a(n&#043;1, 0), b(n&#043;1, 0);<\/p>\n<p>    for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) {<br \/>\n        cin &gt;&gt; a[i];<br \/>\n        int temp &#061; a[i];<br \/>\n        \/\/ \u904d\u5386\u524d\u9762\u6240\u6709\u5143\u7d20<br \/>\n        for(int j &#061; 1; j &lt; i; j&#043;&#043;) {<br \/>\n            if(temp &gt; a[j])  \/\/ \u524d\u9762\u6709\u6bd4\u5f53\u524d\u5c0f\u7684<br \/>\n                b[i]&#043;&#043;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    for(int i &#061; 1; i &lt;&#061; n; i&#043;&#043;)<br \/>\n        cout &lt;&lt; b[i] &lt;&lt; &#039; &#039;;<br \/>\n} <\/p>\n<h4>\u590d\u6742\u5ea6\u5206\u6790<\/h4>\n<table>\n<tr>\u9879\u76ee\u590d\u6742\u5ea6\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u65f6\u95f4\u590d\u6742\u5ea6<\/td>\n<td>O(n\u00b2)<\/td>\n<td>\u53cc\u91cd\u5faa\u73af&#xff0c;\u5916\u5c42n\u6b21&#xff0c;\u5185\u5c42\u5e73\u5747n\/2\u6b21<\/td>\n<\/tr>\n<tr>\n<td>\u7a7a\u95f4\u590d\u6742\u5ea6<\/td>\n<td>O(n)<\/td>\n<td>\u5b58\u50a8\u6570\u7ec4a\u548c\u7b54\u6848b<\/td>\n<\/tr>\n<tr>\n<td>\u6700\u5927\u53ef\u5904\u7406\u89c4\u6a21<\/td>\n<td>n \u2264 10\u2074<\/td>\n<td>10\u2078\u6b21\u64cd\u4f5c\u7ea61\u79d2&#xff0c;n&#061;10\u2074\u65f6\u521a\u597d10\u2078<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u74f6\u9888&#xff1a;\u6bcf\u6b21\u67e5\u8be2&#034;\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6bd4\u5b83\u5c0f&#034;\u90fd\u8981\u904d\u5386\u4e00\u904d&#xff0c;\u505a\u4e86\u5927\u91cf\u91cd\u590d\u5de5\u4f5c\u3002<\/p>\n<hr \/>\n<h3>\u65b9\u6cd5\u4e8c&#xff1a;\u6811\u72b6\u6570\u7ec4\u4f18\u5316 O(n log n)<\/h3>\n<h4>\u6838\u5fc3\u601d\u8def<\/h4>\n<p>\u5173\u952e\u89c2\u5bdf&#xff1a;\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u6570\u636e\u7ed3\u6784&#xff0c;\u652f\u6301\u4e24\u79cd\u64cd\u4f5c&#xff1a;<\/p>\n<li>\n<p>\u67e5\u8be2&#xff1a;\u5df2\u7ecf\u51fa\u73b0\u7684\u6570\u4e2d&#xff0c;\u6709\u591a\u5c11\u4e2a &lt; x<\/p>\n<\/li>\n<li>\n<p>\u63d2\u5165&#xff1a;\u628a\u5f53\u524d\u6570 x \u52a0\u5165\u96c6\u5408&#xff0c;\u4f9b\u540e\u7eed\u67e5\u8be2<\/p>\n<\/li>\n<p>\u6811\u72b6\u6570\u7ec4&#xff08;Fenwick Tree&#xff09; \u6b63\u597d\u6ee1\u8db3&#xff1a;\u5355\u70b9\u4fee\u6539 &#043; \u524d\u7f00\u67e5\u8be2\u90fd\u662f O(log n)\u3002<\/p>\n<p>\u6280\u5de7\u2014\u2014\u79bb\u6563\u5316&#xff1a;\u5982\u679c\u6570\u503c\u5f88\u5927&#xff08;\u598210\u2079&#xff09;&#xff0c;\u76f4\u63a5\u5f00\u6570\u7ec4\u4f1aMLE\u3002\u5148\u5c06\u6570\u503c\u6620\u5c04\u5230 [1, n] \u7684\u7d27\u51d1\u8303\u56f4\u3002<\/p>\n<h4>\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>#include &lt;bits\/stdc&#043;&#043;.h&gt;<br \/>\nusing namespace std;<br \/>\ntypedef long long ll;<\/p>\n<p>const int N &#061; 2e5 &#043; 10;  \/\/ \u6839\u636e\u6570\u636e\u8303\u56f4\u8c03\u6574<\/p>\n<p>int n;<br \/>\nint c[N];  \/\/ \u6811\u72b6\u6570\u7ec4<\/p>\n<p>\/\/  lowbit: \u63d0\u53d6\u4e8c\u8fdb\u5236\u6700\u4f4e\u4f4d\u76841<br \/>\n\/\/  \u4f8b\u5982&#xff1a;6(110) \u2192 2(010),  8(1000) \u2192 8(1000)<br \/>\nint lowbit(int x)<br \/>\n{<br \/>\nreturn x &amp; (-x);<br \/>\n}<\/p>\n<p>\/\/ \u5728\u4f4d\u7f6ex\u589e\u52a0v&#xff0c;\u5e76\u66f4\u65b0\u6240\u6709\u7956\u5148\u8282\u70b9<br \/>\nvoid add(int x, int v)<br \/>\n{<br \/>\nfor (int i &#061; x; i &lt;&#061; n; i &#043;&#061; lowbit(i))<br \/>\nc[i] &#043;&#061; v;<br \/>\n}<\/p>\n<p>\/\/ \u67e5\u8be2[1, x]\u7684\u524d\u7f00\u548c&#xff0c;\u5373\u6709\u591a\u5c11\u4e2a\u6570 \u2264 x<br \/>\nint query(int x)<br \/>\n{<br \/>\nint res &#061; 0;<br \/>\nfor (int i &#061; x; i &gt; 0; i -&#061; lowbit(i))<br \/>\nres &#043;&#061; c[i];<br \/>\nreturn res;<br \/>\n}<\/p>\n<p>int main()<br \/>\n{<br \/>\nios::sync_with_stdio(0);<br \/>\ncin.tie(0);<br \/>\ncout.tie(0);<\/p>\n<p>cin &gt;&gt; n;<br \/>\nvector&lt;int&gt; a(n &#043; 1), b(n &#043; 1);<br \/>\nvector&lt;int&gt; all;  \/\/ \u7528\u4e8e\u79bb\u6563\u5316<\/p>\n<p>\/\/ \u8bfb\u5165\u6570\u636e<br \/>\nfor (int i &#061; 1; i &lt;&#061; n; i&#043;&#043;)<br \/>\n{<br \/>\ncin &gt;&gt; a[i];<br \/>\nall.push_back(a[i]);<br \/>\n}<\/p>\n<p>\/\/ \u79bb\u6563\u5316&#xff1a;\u6392\u5e8f &#043; \u53bb\u91cd<br \/>\nsort(all.begin(), all.end());<br \/>\nall.erase(unique(all.begin(), all.end()), all.end());<\/p>\n<p>\/\/ \u9010\u4e2a\u5904\u7406<br \/>\nfor (int i &#061; 1; i &lt;&#061; n; i&#043;&#043;)<br \/>\n{<br \/>\n\/\/ \u627e\u5230a[i]\u5728all\u4e2d\u7684\u4f4d\u7f6e&#xff08;1-based&#xff09;<br \/>\nint pos &#061; lower_bound(all.begin(), all.end(), a[i]) &#8211; all.begin() &#043; 1;<\/p>\n<p>\/\/ \u67e5\u8be2&#xff1a;\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6570 &lt; a[i]&#xff08;\u5373\u79bb\u6563\u5316\u503c\u5728[1, pos-1]\u8303\u56f4\u5185&#xff09;<br \/>\nb[i] &#061; query(pos &#8211; 1);<\/p>\n<p>\/\/ \u63d2\u5165&#xff1a;\u628a\u5f53\u524d\u6570\u52a0\u5165\u6811\u72b6\u6570\u7ec4<br \/>\nadd(pos, 1);<br \/>\n}<\/p>\n<p>for (int i &#061; 1; i &lt;&#061; n; i&#043;&#043;)<br \/>\ncout &lt;&lt; b[i] &lt;&lt; &#039; &#039;;<\/p>\n<p>return 0;<br \/>\n} <\/p>\n<h3>\u4e24\u79cd\u65b9\u6cd5\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u66b4\u529b O(n\u00b2)\u6811\u72b6\u6570\u7ec4 O(n log n)<\/tr>\n<tbody>\n<tr>\n<td>\u6838\u5fc3\u601d\u60f3<\/td>\n<td>\u9010\u4e2a\u6bd4\u8f83<\/td>\n<td>\u7528\u524d\u7f00\u548c\u5feb\u901f\u8ba1\u6570<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u6b21\u67e5\u8be2<\/td>\n<td>O(n) \u904d\u5386<\/td>\n<td>O(log n) \u4e8c\u5206\u8df3<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u6b21\u63d2\u5165<\/td>\n<td>\u65e0\u9700\u63d2\u5165<\/td>\n<td>O(log n) \u66f4\u65b0<\/td>\n<\/tr>\n<tr>\n<td>\u603b\u65f6\u95f4<\/td>\n<td>O(n\u00b2)<\/td>\n<td>O(n log n)<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u5904\u7406\u89c4\u6a21<\/td>\n<td>n \u2264 10\u2074<\/td>\n<td>n \u2264 10\u2076 ~ 10\u2077<\/td>\n<\/tr>\n<tr>\n<td>\u989d\u5916\u7a7a\u95f4<\/td>\n<td>O(n)<\/td>\n<td>O(n)<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u91cf<\/td>\n<td>\u5c11<\/td>\n<td>\u8f83\u591a&#xff08;\u9700\u5b9e\u73b0\u6811\u72b6\u6570\u7ec4&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u5173\u952e\u6b65\u9aa4\u56fe\u89e3<\/h3>\n<p>\u4ee5 a &#061; [5, 2, 4] \u4e3a\u4f8b&#xff1a;<\/p>\n<p>\u79bb\u6563\u5316&#xff1a;5\u21923, 2\u21921, 4\u21922<\/p>\n<p>\u6811\u72b6\u6570\u7ec4\u7ef4\u62a4\u7684\u662f&#034;\u6bcf\u4e2a\u79bb\u6563\u5316\u503c\u51fa\u73b0\u4e86\u51e0\u6b21&#034;<\/p>\n<p>\u6b65\u9aa41: \u5904\u74065(pos&#061;3)<br \/>\n       \u67e5\u8be2[1,2]\u7684\u548c &#061; 0 \u2192 b[1]&#061;0<br \/>\n       \u5728\u4f4d\u7f6e3\u52a01 \u2192 \u6570\u7ec4: [0,0,1,0]<\/p>\n<p>\u6b65\u9aa42: \u5904\u74062(pos&#061;1)<br \/>\n       \u67e5\u8be2[1,0]\u7684\u548c &#061; 0 \u2192 b[2]&#061;0<br \/>\n       \u5728\u4f4d\u7f6e1\u52a01 \u2192 \u6570\u7ec4: [1,0,1,0]<\/p>\n<p>\u6b65\u9aa43: \u5904\u74064(pos&#061;2)<br \/>\n       \u67e5\u8be2[1,1]\u7684\u548c &#061; 1 \u2192 b[3]&#061;1&#xff08;\u524d\u9762\u67092&#xff09;<br \/>\n       \u5728\u4f4d\u7f6e2\u52a01 \u2192 \u6570\u7ec4: [1,1,1,0] <\/p>\n<hr \/>\n<h3>\u603b\u7ed3<\/h3>\n<table>\n<tr>\u573a\u666f\u63a8\u8350\u65b9\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>n \u2264 5000<\/td>\n<td>\u66b4\u529b&#xff0c;\u7b80\u5355\u4e0d\u6613\u9519<\/td>\n<\/tr>\n<tr>\n<td>n &gt; 10\u2074 \u6216 \u591a\u7ec4\u6d4b\u8bd5<\/td>\n<td>\u6811\u72b6\u6570\u7ec4&#xff0c;\u907f\u514dTLE<\/td>\n<\/tr>\n<tr>\n<td>\u9700\u8981\u6c42\u9006\u5e8f\u5bf9\u3001\u533a\u95f4\u8ba1\u6570<\/td>\n<td>\u6811\u72b6\u6570\u7ec4\u662f\u6807\u51c6\u5de5\u5177<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6811\u72b6\u6570\u7ec4\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e\u5c06&#034;\u904d\u5386\u7edf\u8ba1&#034;\u8f6c\u5316\u4e3a&#034;\u524d\u7f00\u548c\u67e5\u8be2&#034;&#xff0c;\u7528 O(log n) \u7684\u4ee3\u6570\u64cd\u4f5c\u66ff\u4ee3 O(n) \u7684\u7ebf\u6027\u626b\u63cf<\/p>\n<h2>\u7ed3\u8bed:<\/h2>\n<p>\u5e0c\u671b\u672c\u7ae0\u80fd\u591f\u5e2e\u52a9\u5230\u60a8~,\u7801\u5b57\u4e0d\u6613,\u611f\u8c22\u60a8\u7684\u70b9\u8d5e\u6536\u85cfo(*&#xffe3;\u25bd&#xffe3;*)\u30d6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b&#xff1a;\u4ece O(n\u00b2) \u5230 O(n log n)<br \/>\n\u4f8b\u9898\u94fe\u63a5:\u5de6\u4fa7\u4e25\u683c\u5c0f\u4e8e\u8ba1\u6570_\u725b\u5ba2\u9898\u9738_\u725b\u5ba2\u7f51<br \/>\n\u95ee\u9898\u7b80\u8ff0:<br \/>\n\u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n \u7684\u6570\u7ec4 a&#xff0c;\u5bf9\u4e8e\u6bcf\u4e2a\u4f4d\u7f6e i&#xff0c;\u6c42\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6570\u6bd4 a[i] \u5c0f\u3002<br \/>\n\u793a\u4f8b&#xff1a;<br \/>\n\u8f93\u5165&#xff1a;a  [5, 2, 4, 1, 3]<br \/>\n\u8f93\u51fa&#xff1a;0 0 1 0 2<br \/>\n\u89e3\u91ca&#xff1a;<br \/>\n&#8211; i1, a[1]5, \u524d\u9762\u65e0\u6570 \u2192 0<br \/>\n&#8211; i2, a[2]2, \u524d\u9762<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,1813,427],"topic":[],"class_list":["post-76385","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-1813","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76385.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b&#xff1a;\u4ece O(n\u00b2) \u5230 O(n log n) \u4f8b\u9898\u94fe\u63a5:\u5de6\u4fa7\u4e25\u683c\u5c0f\u4e8e\u8ba1\u6570_\u725b\u5ba2\u9898\u9738_\u725b\u5ba2\u7f51 \u95ee\u9898\u7b80\u8ff0: \u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n \u7684\u6570\u7ec4 a&#xff0c;\u5bf9\u4e8e\u6bcf\u4e2a\u4f4d\u7f6e i&#xff0c;\u6c42\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6570\u6bd4 a[i] \u5c0f\u3002 \u793a\u4f8b&#xff1a; \u8f93\u5165&#xff1a;a [5, 2, 4, 1, 3] \u8f93\u51fa&#xff1a;0 0 1 0 2 \u89e3\u91ca&#xff1a; - i1, a[1]5, \u524d\u9762\u65e0\u6570 \u2192 0 - i2, a[2]2, \u524d\u9762\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76385.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-22T04:17:08+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76385.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76385.html\",\"name\":\"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-22T04:17:08+00:00\",\"dateModified\":\"2026-02-22T04:17:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76385.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76385.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76385.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76385.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b&#xff1a;\u4ece O(n\u00b2) \u5230 O(n log n) \u4f8b\u9898\u94fe\u63a5:\u5de6\u4fa7\u4e25\u683c\u5c0f\u4e8e\u8ba1\u6570_\u725b\u5ba2\u9898\u9738_\u725b\u5ba2\u7f51 \u95ee\u9898\u7b80\u8ff0: \u7ed9\u5b9a\u4e00\u4e2a\u957f\u5ea6\u4e3a n \u7684\u6570\u7ec4 a&#xff0c;\u5bf9\u4e8e\u6bcf\u4e2a\u4f4d\u7f6e i&#xff0c;\u6c42\u524d\u9762\u6709\u591a\u5c11\u4e2a\u6570\u6bd4 a[i] \u5c0f\u3002 \u793a\u4f8b&#xff1a; \u8f93\u5165&#xff1a;a [5, 2, 4, 1, 3] \u8f93\u51fa&#xff1a;0 0 1 0 2 \u89e3\u91ca&#xff1a; - i1, a[1]5, \u524d\u9762\u65e0\u6570 \u2192 0 - i2, a[2]2, \u524d\u9762","og_url":"https:\/\/www.wsisp.com\/helps\/76385.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-22T04:17:08+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76385.html","url":"https:\/\/www.wsisp.com\/helps\/76385.html","name":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-22T04:17:08+00:00","dateModified":"2026-02-22T04:17:08+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76385.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76385.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76385.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b80\u5355\u5229\u7528\u6811\u72b6\u6570\u7ec4\u4f18\u5316\u5b9e\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76385","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76385"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76385\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76385"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}