{"id":88,"date":"2026-10-09T19:24:30","date_gmt":"2026-10-09T11:24:30","guid":{"rendered":"http:\/\/189.24.78.16\/?p=88"},"modified":"2026-10-09T19:24:31","modified_gmt":"2026-10-09T11:24:31","slug":"%e6%97%a5%e5%b8%b8%e5%86%99%e9%a2%98cf2075c-two-colors","status":"publish","type":"post","link":"https:\/\/bkxiaohei123.xyz\/index.php\/2026\/10\/09\/%e6%97%a5%e5%b8%b8%e5%86%99%e9%a2%98cf2075c-two-colors\/","title":{"rendered":"\u65e5\u5e38\u5199\u9898:CF2075C Two Colors"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.luogu.com.cn\/problem\/CF2075C\" data-type=\"link\" data-id=\"https:\/\/www.luogu.com.cn\/problem\/CF2075C\">\u95ee\u9898\u94fe\u63a5<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u95ee\u9898\u7b80\u8981\u6982\u62ec\uff0c\u7ed9\u4f60n\u4e2a\u56f4\u680f,m\u79cd\u67d3\u6599\uff0c\u6bcf\u79cd\u6700\u591a\u53ef\u4ee5\u8fde\u7eed\u67d3\u8272<em>ai<\/em>\u4e2a\u56f4\u680f\uff0c\u9009\u53d6\u4e24\u79cd\u989c\u8272 <em>x<\/em>,<em>y<\/em>\uff0c\u5e76\u5c06\u65b9\u683c\u5206\u4e3a\u4e24\u534a\uff0c\u5de6\u8fb9\u5168\u6d82\u4e3a\u989c\u8272 <em>x<\/em>\uff0c\u53f3\u8fb9\u5168\u6d82\u4e3a\u989c\u8272 <em>y<\/em>\u3002\u6c42\u4e0d\u540c\u7684\u65b9\u6848\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u9053\u9898\u8fd0\u7528\u4e8c\u5206\u89e3\u6cd5\u5c06\u4f1a\u975e\u5e38\u597d\u7406\u89e3\uff0c\u6211\u4eec\u53ef\u4ee5\u5148\u5c06\u6240\u6709\u989c\u8272\u53ef\u4ee5\u67d3\u8272\u7684\u6570\u91cf\u6392\u5e8f\uff0c\u8fbe\u6210\u4e8c\u5206\u6cd5\u7684\u6709\u5e8f\u6027\u7684\u6761\u4ef6\uff0c\u7136\u540e\u6211\u4eec\u53ef\u4ee5\u904d\u5386\u4e24\u79cd\u989c\u8272\u7684\u5206\u5272\u70b9k \u679a\u4e3e \u4ece 1 \u5230 n &#8211; 1\uff08\u6761\u4ef6\u8981\u6c42\u5fc5\u987b\u4e24\u79cd\u989c\u8272\uff09, \u5e76\u901a\u8fc7\u4e8c\u5206\u6cd5\u5bfb\u627e\u80fd\u591f\u6ee1\u8db3\u67d3\u8272\u6570\u91cf\u5927\u4e8e\u7b49\u4e8ek\u524d\u9762\u56f4\u680f\u6570\u91cf\u7684\u989c\u8272\u79cd\u7c7b\u6570x\uff0c\u540c\u65f6\u5bfb\u627e\u6ee1\u8db3\u67d3\u8272\u6570\u91cf\u5927\u4e8e\u7b49\u4e8ek\u540e\u9762\u7684\u56f4\u680f\u6570\u91cf\u7684\u989c\u8272\u79cd\u7c7b\u6570y\uff0c\u901a\u8fc7\u601d\u8003\u6613\u5f97\u51fa \u65b9\u6848\u6570 \u4e3a x*y &#8211; min(x,y),x*y\u90e8\u5206\u6211\u4eec\u5f88\u597d\u7406\u89e3\u56e0\u4e3a\u5c31\u662f\u4e24\u79cd\u989c\u8272\u79cd\u7c7b\u6570\u76f8\u4e58\u5f97\u51fa\u5171\u6709\u591a\u5c11\u79cd\u65b9\u6848\uff0c\u4f46\u662f\u9898\u4e2d\u8981\u6c42\u5fc5\u987b\u989c\u8272\u6570\u4e3a\u4e24\u79cd\uff0c\u82e5x=y\u5219\u4e0d\u80fd\u8ba1\u5165\u65b9\u6848\u6570\uff0c\u56e0\u6b64\u540e\u9762\u7684min\uff08x,y\uff09\u4fbf\u662f\u51cf\u53bb\u7684\u65b9\u6848\u6570\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u6211\u4eec\u53c8\u6709\u4e86\u65b0\u7591\u60d1\uff0c\u4e3a\u4ec0\u4e48min\uff08x,y\uff09\u5c31\u80fd\u6c42\u51fa\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u65b9\u6848\u6570\uff0c\u6211\u4eec\u89c2\u5bdfx\u548cy\uff0c\u53ef\u4ee5\u770b\u51fa\uff0cx\u548cy\u5b58\u5728\u8054\u7cfb\u6027\uff0c\u82e5x\u6ee1\u8db3>=k\uff0cy\u6ee1\u8db3>=n-k,\u53ef\u5f97\u51fay>=k\uff08\u524d\u63d0\u6761\u4ef6n-k>k\uff09\uff0c\u53cd\u8fc7\u6765\u4e5f\u4e00\u6837\uff0c\u56e0\u6b64\u5f53x\u53ef\u4ee5\u6d82\u6389\u5de6\u8fb9\u65f6\uff0cy\u4e5f\u53ef\u4ee5\u505a\u5230\uff0c\u5373x\u7684\u65b9\u6848\u6570\u4e3ay\u7684\u65b9\u6848\u6570\u5b50\u96c6\uff0cmin\uff08x,y\uff09\u4fbf\u80fd\u5f97\u51fax\u548cy\u7684\u5171\u96c6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9898\u89e3\uff1a<\/p>\n\n\n\n<div class=\"wp-block-scb-code-block scb-code-wrap\"><div class=\"scb-code-toolbar\"><span class=\"scb-code-language\">CPP<\/span><button type=\"button\" class=\"scb-copy-button\">\u590d\u5236\u4ee3\u7801<\/button><\/div><pre><code class=\"language-cpp\">#include&lt;bits\/std++.h>\nusing namespace std;\n#define int long long\nint a[200100];\nvoid resolve()\n{\t\n\tint n, m;\n\tmemset(a, 0, sizeof(a));\n\tcin >> n >> m;\n\tfor (int i = 0; i &lt; m; i++)\n\t{\n\t\tcin >> a[i];\n\t}\n\tsort(a, a + m);\n\tint ans = 0;\n\tfor (int i = 1; i &lt; n; i++)\n\t{\n\t\tint x = m - (lower_bound(a, a + m, i) - a);\n\t\tint y = m - (lower_bound(a, a + m, n - i) - a);\n\t\tans += x * y - min(x, y);\n\t}\n\tcout &lt;&lt; ans &lt;&lt; endl;\n\n}\n\n\nsigned main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tint T;\n\tcin >> T;\n\twhile (T--)\n\t\tresolve();\n}<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u94fe\u63a5 \u95ee\u9898\u7b80\u8981\u6982\u62ec\uff0c\u7ed9\u4f60n\u4e2a\u56f4\u680f,m\u79cd\u67d3\u6599\uff0c\u6bcf\u79cd\u6700\u591a\u53ef\u4ee5\u8fde\u7eed\u67d3\u8272ai\u4e2a\u56f4\u680f\uff0c\u9009\u53d6\u4e24\u79cd\u989c\u8272 x,y\uff0c\u5e76\u5c06\u65b9\u683c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":91,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14,15,13],"class_list":["post-88","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learning","tag-c","tag-15","tag-13"],"_links":{"self":[{"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":2,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":90,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions\/90"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/media\/91"}],"wp:attachment":[{"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bkxiaohei123.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}