{"id":296,"date":"2012-12-08T22:51:00","date_gmt":"2012-12-08T14:51:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/201"},"modified":"2012-12-08T22:51:00","modified_gmt":"2012-12-08T14:51:00","slug":"cf_253c_looking_for_a_career_change","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=296","title":{"rendered":"CF 253C(\u627e\u4e2d\u8f6c\u884c)"},"content":{"rendered":"<div style=\"margin:0px; padding:0px; font-family:verdana,arial,sans-serif; font-size:14px; position:relative\">\n<div id=\"content\" class=\"content-with-sidebar\" style=\"margin:1em; padding:1em 0px 0px; min-height:20em\">\n<div class=\"ttypography\" style=\"margin:0px; padding:0px; font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; line-height:21px; color:rgb(34,34,34); word-wrap:break-word\">\n<div class=\"problem-statement\" style=\"margin:0.5em; padding:0px; line-height:1.5em\">\n<div class=\"header\" style=\"margin:0px 0px 1em; padding:0px; text-align:center\">\n<div class=\"title\" style=\"margin:0px 0px 0.5em; padding:0px; font-size:21px\">C. \u5149\u6807\u79fb\u52a8<\/div>\n<div class=\"time-limit\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\ntime limit per test<\/div>\n<p>1 second<\/p><\/div>\n<div class=\"memory-limit\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\nmemory limit per test<\/div>\n<p>256 megabytes<\/p><\/div>\n<div class=\"input-file\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\ninput<\/div>\n<p>input.txt<\/p><\/div>\n<div class=\"output-file\" style=\"margin:0px auto; padding:0px\">\n<div class=\"property-title\" style=\"margin:0px; padding:0px 4px 0px 0px; display:inline\">\noutput<\/div>\n<p>output.txt<\/p><\/div>\n<\/div>\n<div style=\"margin:0px; padding:0px\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\n<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u6587\u672c\u7f16\u8f91\u5668\u6709n\u884c\uff0c\u6bcf\u884ck\u4e2a\u5b57\u7b26\uff08\u663e\u7136\u5149\u6807\u6709k&#43;1\u4e2a\u4f4d\u7f6e\uff0c\u6807\u8bb0\u4e3a1..k&#43;1.<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u67094\u4e2a\u64cd\u4f5c\uff1a<\/p>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\n&quot;Up&quot;: \u5149\u6807\u5c06\u5411\u4e0a\u79fb1\u884c\uff0c\u5217\u4e0d\u53d8\u3002\u5982\u679c\u4e0a\u4e00\u884c\u5b57\u7b26\u592a\u5c11\uff0c\u5219\u5149\u6807\u8dd1\u5230\u884c\u672b\u3002<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<\/li>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\n&quot;Down&quot;: <span style=\"color:rgb(34,34,34); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; line-height:21px\"><br \/>\n\u5149\u6807\u5c06\u5411\u4e0b\u79fb1\u884c\uff0c\u5217\u4e0d\u53d8\u3002\u5982\u679c\u4e0a\u4e00\u884c\u5b57\u7b26\u592a\u5c11\uff0c\u5219\u5149\u6807\u8dd1\u5230\u884c\u672b\u3002<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<\/li>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\n&quot;Right&quot;: \u5149\u6807\u5411\u53f3\u79fb1&#26684;\uff0c\u64cd\u4f5c\u4e0d\u80fd\u5728\u884c\u672b\u8fdb\u884c\u3002<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<\/li>\n<li style=\"margin:0px 0px 0px 0.8em; padding:0px; line-height:1.5em; font-size:1em\">\n&quot;Left&quot;: <span style=\"color:rgb(34,34,34); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; line-height:21px\"><br \/>\n\u5149\u6807\u5411\u5de6\u79fb1&#26684;\uff0c\u64cd\u4f5c\u4e0d\u80fd\u5728\u884c\u9996\u8fdb\u884c\u3002<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u6c42\u51fa\u628a\u5149\u6807\u4ece&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(<em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>)<\/span>&nbsp;\u79fb\u5411<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">(<em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>)<span style=\"color:rgb(34,34,34); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; line-height:21px\">\u6700\u5c0f\u6b65\u6570<\/span><\/span>.<\/p>\n<\/li>\n<\/div>\n<div class=\"input-specification\" style=\"margin:0px; padding:0px\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-size:16px; font-weight:bold\">\nInput<\/div>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u7b2c\u4e00\u884c\u4e00\u4e2a\u6574\u6570&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">1\u2009\u2264\u2009<em>n<\/em>\u2009\u2264\u2009100<\/span>) . \u7b2c\u4e8c\u884c&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>n<\/em><\/span>\u4e2a\u6574\u6570<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009...,\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>n<\/em><\/sub><\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">0\u2009\u2264\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>i<\/em><\/sub>\u2009\u2264\u200910<sup class=\"upper-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; top:-0.5em\">5<\/sup><\/span>),<br \/>\n \u8868\u793a\u6bcf\u884c\u5b57\u7b26\u6570. \u7b2c\u4e09\u884c4\u4e2a\u6574\u6570&nbsp;<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\"><em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>,\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub><\/span>&nbsp;(<span class=\"tex-span\" style=\"font-size:18px; font-family:'times new roman',sans-serif\">1\u2009\u2264\u2009<em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>,\u2009<em>r<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>\u2009\u2264\u2009<em>n<\/em>,\u20091\u2009\u2264\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>\u2009\u2264\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>r<\/em><\/sub><sub class=\"lower-index\" style=\"font-size:12px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">1<\/sub>\u2009&#43;\u20091,\u20091\u2009\u2264\u2009<em>c<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>\u2009\u2264\u2009<em>a<\/em><sub class=\"lower-index\" style=\"font-size:13px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\"><em>r<\/em><\/sub><sub class=\"lower-index\" style=\"font-size:12px; line-height:0; position:relative; vertical-align:baseline; bottom:-0.25em\">2<\/sub>\u2009&#43;\u20091<\/span>).<\/p>\n<\/div>\n<div class=\"output-specification\" style=\"margin:0px 0px 1em; padding:0px\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-size:16px; font-weight:bold\">\nOutput<\/div>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u8f93\u51fa\u6700\u5c0f\u6b65\u6570<\/p>\n<\/div>\n<div class=\"sample-tests\" style=\"margin:0px; padding:0px; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; font-size:0.9em\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; font-weight:bold\">\nSample test(s)<\/div>\n<div class=\"sample-test\" style=\"margin:0px; padding:0px\">\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">4\n2 1 6 4\n3 4 4 2\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">3\n<\/pre>\n<\/div>\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">4\n10 5 6 4\n1 11 4 2\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">6\n<\/pre>\n<\/div>\n<div class=\"input\" style=\"margin:0px; padding:0px; border:1px solid rgb(136,136,136)\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\ninput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">3\n10 1 10\n1 10 1 1\n<\/pre>\n<\/div>\n<div class=\"output\" style=\"margin:0px 0px 1em; padding:0px; border:1px solid rgb(136,136,136); position:relative; top:-1px\">\n<div class=\"title\" style=\"margin:0px; padding:0.25em; font-size:1.3em; border-bottom-width:1px; border-bottom-style:solid; border-bottom-color:rgb(136,136,136); text-transform:lowercase; font-weight:bold\">\noutput<\/div>\n<pre style=\"margin-top:0px; margin-bottom:0px; padding:0.25em; font-family:Consolas,'Lucida Console','Andale Mono','Bitstream Vera Sans Mono','Courier New',Courier; line-height:1.25em; white-space:pre-wrap; word-wrap:break-word; color:rgb(136,0,0); background-color:rgb(239,239,239)\">3\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"note\" style=\"margin:0px; padding:0px\">\n<div class=\"section-title\" style=\"margin:0px; padding:0px; font-size:16px; font-weight:bold\">\nNote<\/div>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u7b2c\u4e00\u7ec4\u6570\u636e\u82e5\u4e3a<\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">123<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">12<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">123s567<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n<span class=\"tex-font-style-tt\" style=\"font-size:15px; font-family:'courier new',monospace\">1t345<\/span><\/p>\n<p style=\"margin-top:1.5em; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-size:1em; line-height:1.5em\">\n\u5219\u6700\u5c0f\u64cd\u4f5c\u4e3a &quot;Left&quot;, &quot;Down&quot;, &quot;Left&quot;.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>\n<\/p>\n<p><span style=\"font-size:14px\">\u663e\u7136\u9664\u4e86\u76f4\u63a5\u79fb(\u5148\u884c\u540e\u5217\uff09\u5916\uff0c<\/span><\/p>\n<p><span style=\"font-size:14px\">\u552f\u4e00\u51cf\u5c11\u64cd\u4f5c\u6570\u7684\u65b9\u6cd5\u4fbf\u662f\u5411\u4e2d\u95f4\u4ee5\u5916\u7684\u884c\u6570\u79fb\uff0c\u4ee5\u6c42\u964d\u4f4e\u5217\u7684\u79fb\u52a8\u6570\u3002<\/span><\/p>\n<p><span style=\"font-size:14px\">\u4e00\u5b9a\u8981\u6ce8\u610f\u4e0d\u662f\u632a\u5230\u6bcf\u884c\u76f4\u63a5\u53d6abs(\u884c\u5c3e-c2)\u7684\uff0c\u56e0\u4e3a\u53ef\u80fd\u4f1a\u6709\u5f80\u8fd4\u884c\u5c3e\u7684\u8def\u4e0a\u6709\u66f4\u5c0f\u7684\uff0c\u76f4\u63a5\u53d6\u884c\u5c3e\u53ef\u80fd\u62c9\u8fd1\u5b83\u548cc2\u7684\u8ddd\u79bb\uff0c\u4f46\u662f\u8fd9\u79cd\u64cd\u4f5c\u662f\u4e0d\u53ef\u884c\u7684\u3002<\/span><\/p>\n<p>\n<\/p>\n<\/p>\n<pre name=\"code\" class=\"cpp\">#include&lt;cstdio&gt;\n#include&lt;functional&gt;\n#include&lt;algorithm&gt;\n#include&lt;cstdlib&gt;\n#include&lt;cstring&gt;\n#include&lt;iostream&gt;\nusing namespace std;\n#define MAXN (10000+100)\nint a[MAXN],n;\nint abs2(int a,int b)\n{\n\tif (a&lt;b) return b-a;\n\telse return a-b;\n}\nint main()\n{\n\tfreopen(&quot;input.txt&quot;,&quot;r&quot;,stdin);\n\tfreopen(&quot;output.txt&quot;,&quot;w&quot;,stdout);\n\tscanf(&quot;%d&quot;,&amp;n);\n\tfor (int i=1;i&lt;=n;i++) scanf(&quot;%d&quot;,&amp;a[i]);\n\tint r1,c1,r2,c2;\n\tscanf(&quot;%d%d%d%d&quot;,&amp;r1,&amp;c1,&amp;r2,&amp;c2);\n\tint mi=c1,ans=0,tans=1000000000;\n\tif (r1&lt;r2)\n\t{\n\t\tans=r2-r1;\n\t\tfor (int i=r1+1;i&lt;=r2;i++) mi=min(mi,a[i]+1);\n\t\ttans=min(tans,ans+abs(mi-c2));\n\t\tfor (int i=r1-1,cost=2,mii=mi;i&gt;=1;i--,cost+=2)\n\t\t{\n\t\t\tmii=min(mii,a[i]+1);\n\t\t\ttans=min(tans,ans+cost+abs(mii-c2));\n\t\t}\n\t\tfor (int i=r2+1,cost=2,mii=mi;i&lt;=n;i++,cost+=2)\n\t\t{\n\t\t\tmii=min(mii,a[i]+1);\n\t\t\ttans=min(tans,ans+cost+abs(mii-c2));\n\t\t}\n\t}\n\telse\n\t{\n\t\tans=r1-r2;\n\t\tfor (int i=r1-1;i&gt;=r2;i--) mi=min(mi,a[i]+1);\n\t\ttans=min(tans,ans+abs(mi-c2));\n\t\tfor (int i=r2-1,cost=2,mii=mi;i&gt;=1;i--,cost+=2)\n\t\t{\n\t\t\tmii=min(mii,a[i]+1);\n\t\t\ttans=min(tans,ans+cost+abs(mii-c2));\n\t\t}\n\t\tfor (int i=r1+1,cost=2,mii=mi;i&lt;=n;i++,cost+=2)\n\t\t{\n\t\t\tmii=min(mii,a[i]+1);\n\t\t\ttans=min(tans,ans+cost+abs(mii-c2));\n\t\t}\n\t}\n\tcout&lt;&lt;tans&lt;&lt;endl;\n\treturn 0;\n}<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C. \u5149\u6807\u79fb\u52a8 time limit per test 1 second memory limit per t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[118],"class_list":["post-296","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-greedy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good<\/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:\/\/nike0good.com\/?p=296\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good\" \/>\n<meta property=\"og:description\" content=\"C. \u5149\u6807\u79fb\u52a8 time limit per test 1 second memory limit per t [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=296\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2012-12-08T14:51:00+00:00\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\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\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"CF 253C(\u627e\u4e2d\u8f6c\u884c)\",\"datePublished\":\"2012-12-08T14:51:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296\"},\"wordCount\":95,\"commentCount\":0,\"keywords\":[\"\u8d2a\u5fc3\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=296#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=296\",\"name\":\"CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"datePublished\":\"2012-12-08T14:51:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=296\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=296#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CF 253C(\u627e\u4e2d\u8f6c\u884c)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good","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:\/\/nike0good.com\/?p=296","og_locale":"zh_CN","og_type":"article","og_title":"CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good","og_description":"C. \u5149\u6807\u79fb\u52a8 time limit per test 1 second memory limit per t [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=296","og_site_name":"nike0good","article_published_time":"2012-12-08T14:51:00+00:00","author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=296#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=296"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"CF 253C(\u627e\u4e2d\u8f6c\u884c)","datePublished":"2012-12-08T14:51:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=296"},"wordCount":95,"commentCount":0,"keywords":["\u8d2a\u5fc3"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=296#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=296","url":"https:\/\/nike0good.com\/?p=296","name":"CF 253C(\u627e\u4e2d\u8f6c\u884c) - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"datePublished":"2012-12-08T14:51:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=296#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=296"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=296#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"CF 253C(\u627e\u4e2d\u8f6c\u884c)"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/296\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}