{"id":35,"date":"2022-06-04T10:52:00","date_gmt":"2022-06-04T02:52:00","guid":{"rendered":"http:\/\/ubuntu.tim-wcx.ltd\/wordpress\/index.php\/2022\/06\/04\/2020-08-09\/"},"modified":"2022-06-04T10:52:00","modified_gmt":"2022-06-04T02:52:00","slug":"2020-08-09","status":"publish","type":"post","link":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/2022\/06\/04\/2020-08-09\/","title":{"rendered":"2020-08-09"},"content":{"rendered":"<p><svg  style=\"display: none;\">\n                        <path stroke-linecap=\"round\" d=\"M5,0 0,2.5 5,5z\" id=\"raphael-marker-block\" style=\"-webkit-tap-highlight-color: rgba(0, 0, 0, 0);\"><\/path>\n                    <\/svg><\/p>\n<p><a href=\"http:\/\/icpc.upc.edu.cn\/problem.php?id=14866\">http:\/\/icpc.upc.edu.cn\/problem.php?id=14866<\/a><\/p>\n<h5><a id=\"_1\"><\/a>\u9898\u76ee<\/h5>\n<p>14866: \u9ad8\u5174\u5929\u6570<\/p>\n<h5><a id=\"_3\"><\/a>\u9898\u76ee\u63cf\u8ff0<\/h5>\n<p>\u5c0fX\u6027\u683c\u5f88\u72ec\u7279\uff0c\u5982\u679c\u5979\u4eca\u5929\u9ad8\u5174\u5ea6\u6bd4\u4e0a\u6b21\u4e00\u6837\u6216\u66f4\u9ad8\uff0c\u5979\u5c31\u4f1a\u5f88\u5584\u826f\uff0c\u76f8\u53cd\uff0c\u5982\u679c\u5979\u4eca\u5929\u9ad8\u5174\u5ea6\u6bd4\u4e0a\u6b21\u4f4e\uff0c\u5979\u5c31\u4f1a\u5f88\u51f6\uff01\u73b0\u5728\u5df2\u7ecf\u77e5\u9053\u5c0fX\u5728N\u5929\u91cc\u6bcf\u5929\u7684\u9ad8\u5174\u5ea6M\u3002\u6839\u636e\u8fd9N\u5929\u4e2d\u5979\u6bcf\u5929\u9ad8\u5174\u5ea6M\uff0c\u5408\u7406\u5b89\u6392\u4e0e\u5979\u76f8\u5904\u65f6\u95f4\uff0c\u4f7f\u5927\u5bb6\u4e0e\u5c0fX\u53cb\u597d\u76f8\u5904\u5c3d\u91cf\u591a\u5929\u6570\u3002\u73b0\u5728\u8981\u6c42\u8ba1\u7b97\u51fa\u6700\u591a\u80fd\u548c\u5c0fX\u53cb\u597d\u76f8\u5904\u591a\u5c11\u5929\u3002<\/p>\n<h5><a id=\"_5\"><\/a>\u8f93\u5165<\/h5>\n<p>\u51712\u884c\uff0c\u7b2c\u4e00\u884c\u4e3a\u4e00\u4e2aN\uff0c\u7b2c\u4e8c\u884c\u4e3aN\u4e2a\u6570\uff0c\u4e3a\u5c0fX\u6bcf\u5929\u7684\u9ad8\u5174\u7a0b\u5ea6M\u3002<\/p>\n<h5><a id=\"_7\"><\/a>\u8f93\u51fa<\/h5>\n<p>\u51711\u4e2a\u6570\uff0c\u6700\u591a\u80fd\u548c\u5c0fX\u53cb\u597d\u76f8\u5904\u591a\u5c11\u5929\u3002<\/p>\n<h5><a id=\"_9\"><\/a>\u6837\u4f8b\u8f93\u5165<\/h5>\n<pre><code>5\n2 3 5 6 4 \n<\/code><\/pre>\n<h5><a id=\"_14\"><\/a>\u6837\u4f8b\u8f93\u51fa<\/h5>\n<pre><code>4\n<\/code><\/pre>\n<h5><a id=\"_18\"><\/a>\u63d0\u793a<\/h5>\n<p>\u5bf9\u4e8e30%\u7684\u6570\u636e\uff0cN<=8000<br \/> \u5bf9\u4e8e100%\u7684\u6570\u636e\uff0cN\uff0cM<31000<\/p>\n<h6><a id=\"_21\"><\/a>\u89e3\u6790<\/h6>\n<p>\u4e8c\u5206\u6cd5\u6c42\u6700\u5927\u4e0a\u5347\u5b50\u5e8f\u5217<br \/> \u8fd9\u91cc\u89e3\u91ca\u4e00\u4e0b\uff1a\u9898\u76ee\u6240\u8bf4\u7684\u201c\u6bd4\u4e0a\u6b21\u201d\u662f\u6307\u6211\u4eec\u548c\u5979\u76f8\u5904\u7684\u4e0a\u4e00\u6b21\uff0c\u800c\u4e0d\u662f\u6307\u524d\u4e00\u5929\u3002\u4f8b\u5982\uff0c\u7b2c\u4e09\u5929\u548c\u5979\u76f8\u5904\u540e\u9694\u4e86\u4e24\u5929\u540e\u5373\u7b2c\u516d\u5929\u53c8\u4e0e\u5979\u76f8\u5904\uff0c\u5e94\u8be5\u62ff\u7b2c\u516d\u5929\u5fc3\u60c5\u548c\u7b2c\u4e09\u5929\u5fc3\u60c5\u6bd4\u8f83\u3002<\/p>\n<pre><code>#include <iostream>\n#include <bits\/stdc++.h>\nusing namespace std;\ntypedef long long ll;\nll a[300500]={0};\nll c[300500]={0};\nint main()\n{\n    ll n,cnt=0;\n    scanf(\"%lld\",&n);\n    for(ll i=1;i<=n;i++)\n        scanf(\"%lld\",a+i);\n    for(ll i=1;i<=n;i++)\n    {\n        if(a[i]>=c[cnt])\n        {\n            c[++cnt]=a[i];\n        }\n        else\n        {\n            ll l=1,r=cnt+1;\n            while(l<r)\n            {\n                ll mid=(l+r)\/2;\n                if(a[i]>c[mid])\n                {\n                    l=mid+1;\n                }\n                else if(a[i]<c[mid])\n                {\n                    r=mid;\n                }\n                else if(a[i]==c[mid])\n                {\n                    l=mid+1;\n                }\n            }\n            c[l]=min(c[l],a[i]);\n        }\n    }\n    printf(\"%lldn\",cnt);\n    return 0;\n}\n\n<\/code><\/pre>\n<p><a href=\"http:\/\/icpc.upc.edu.cn\/problem.php?id=15036\">http:\/\/icpc.upc.edu.cn\/problem.php?id=15036<\/a><\/p>\n<h5><a id=\"_71\"><\/a>\u9898\u76ee<\/h5>\n<p>15036: \u9009\u62e9<\/p>\n<h5><a id=\"_73\"><\/a>\u9898\u76ee\u63cf\u8ff0<\/h5>\n<p>\u54c8\u54c8\u54c8\uff0c\u5feb\u5fd8\u6389\u4f60\u7684\u70e6\u5fc3\u4e8b\uff0c\u627e\u5f20\u4f4d\u5b50\u5750\u4e0b\u6765\u3002<br \/> beny\u548cfife\u4e24\u4eba\u4f5c\u4e3a\u5f7c\u6b64\u7089\u8fb9\u597d\u53cb\uff0c\u51b3\u5b9a\u6765\u4e00\u573a\u60ca\u5fc3\u52a8\u9b44\u7684\u53cb\u8c0a\uff08py\uff09\u8d5b\u3002<br \/> fife\u6709n\u4e2a\u968f\u4ece\uff0c\u7b2ci\u4e2a\u968f\u4ece\u6709\u4e00\u4e2a\u80fd\u529b\u503c\uff0c\u4e3aA[i]\u3002<br \/> beny\u4e5f\u6709\u5bf9\u5e94\u7684n\u4e2a\u968f\u4ece\uff0c\u7b2ci\u4e2a\u968f\u4ece\u540c\u6837\u4e5f\u6709\u4e00\u4e2a\u80fd\u529b\u503c\uff0c\u4e3aB[i]\u3002<br \/> \u7136\u540e\uff0c\u4e00\u7fa4\u968f\u4ece\u7684\u6218\u6597\u529b\u4e3a\u8fd9\u7fa4\u968f\u4ece\u80fd\u529b\u503c\u7684\u603b\u548c\u3002<br \/> \u73b0\u5728\uff0cbeny\u548cfife\u6bcf\u4e2a\u4eba\u90fd\u6d3e\u51fa\u81ea\u5df1\u7b2cL\u4e2a\u5230\u7b2cR\u4e2a\uff08\u5171R-L+1\u4e2a\u968f\u4ece\uff09\uff0c\u6765\u4e00\u51b3\u9ad8\u4e0b\u3002<br \/> \u4f46\u662f\u7531\u4e8e\u4ed6\u4eec\u5728\u4e00\u7edd\u9ad8\u4e0b\u7684\u540c\u65f6\u8981py\u4efb\u52a1\uff0c\u4ed6\u4eec\u8981\u4f60\u9009\u62e9\u4e00\u5bf9(L,R)\uff0c\u4f7f\u53cc\u65b9\u6218\u6597\u529b\u5dee\u8ddd\u6700\u5c0f\u3002<br \/> \u4ed6\u4eec\u8981\u4f60\u8f93\u51fa\u6700\u5c0f\u7684\u6218\u6597\u529b\u5dee\u8ddd\uff08\u6218\u6597\u529b\u8f83\u5927\u7684\u51cf\u6218\u6597\u529b\u8f83\u5c0f\u7684\uff09\u3002<\/p>\n<h5><a id=\"_82\"><\/a>\u8f93\u5165<\/h5>\n<p>\u7b2c\u4e00\u884c\u4e00\u4e2a\u6b63\u6574\u6570n\u3002<br \/> \u7b2c\u4e8c\u884cn\u4e2a\u6574\u6570\uff0c\u8868\u793a\u6570\u7ec4A\u3002<br \/> \u7b2c\u4e09\u884cn\u4e2a\u6574\u6570\uff0c\u8868\u793a\u6570\u7ec4B\u3002<\/p>\n<h5><a id=\"_86\"><\/a>\u8f93\u51fa<\/h5>\n<p>\u4e00\u884c\u4e00\u4e2a\u6b63\u6574\u6570\uff0c \u8868\u793a\u6700\u5c0f\u7684\u6218\u6597\u529b\u5dee\u8ddd\u3002<\/p>\n<h5><a id=\"_88\"><\/a>\u6837\u4f8b\u8f93\u5165<\/h5>\n<p>\u3010\u6837\u4f8b1\u3011<br \/> 3<br \/> 4 2 3<br \/> 3 4 2<br \/> \u3010\u6837\u4f8b2\u3011<br \/> 5<br \/> 38 19 5 17 3<br \/> 15 22 0 6 17<\/p>\n<h5><a id=\"_97\"><\/a>\u6837\u4f8b\u8f93\u51fa<\/h5>\n<p>\u3010\u6837\u4f8b1\u3011<br \/> 0<br \/> \u3010\u6837\u4f8b2\u3011<br \/> 1<\/p>\n<h5><a id=\"_102\"><\/a>\u63d0\u793a<\/h5>\n<p>\u6837\u4f8b1\u89e3\u91ca\uff1aL = 1\uff0c R = 3<br \/> \u6837\u4f8b2\u89e3\u91ca\uff1aL = 2\uff0c R = 5<br \/> <img decoding=\"async\" src=\"https:\/\/imgconvert.csdnimg.cn\/aHR0cDovL2ljcGMudXBjLmVkdS5jbi91cGxvYWQvaW1hZ2UvMjAyMDAzMTUvMjAyMDAzMTUxNzI3MDZfOTE4NDAuanBn?x-oss-process=image\/format,png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\"><br \/> set\u7684\u5e94\u7528<\/p>\n<pre><code>#include <bits\/stdc++.h>\nusing namespace std;\ntypedef long long ll;\nll a[300500]={0};\nll b[300500]={0};\nll c[300500]={0};\nset<ll>::iterator it1,it2;\nll x,y,n,ans=99999999999;\nset<ll>w;\nint main()\n{\n    scanf(\"%lld\",&n);\n    for(ll i=1;i<=n;i++)\n        scanf(\"%lld\",&#038;a[i]);\n    for(ll i=1;i<=n;i++)\n    {\n        scanf(\"%lld\",&#038;b[i]);\n        c[i]=c[i-1]+b[i]-a[i];\n    }\n    w.insert(0);\n    w.insert(99999999999);\n    for(ll i=1;i<=n;i++)\n    {\n        it1=w.upper_bound(c[i]);\n        it2=it1;\n        it2--;\n        x=*it1;\n        y=*it2;\n        ans=min(ans,abs(c[i]-x));\n        ans=min(ans,abs(c[i]-y));\n        w.insert(c[i]);\n    }\n    printf(\"%lldn\",ans);\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/icpc.upc.edu.cn\/pr&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.tim-wcx.ltd\/index.php\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}