{"id":355,"date":"2017-12-27T20:00:54","date_gmt":"2017-12-27T12:00:54","guid":{"rendered":"http:\/\/kylelv.com\/?p=355"},"modified":"2017-12-27T20:01:04","modified_gmt":"2017-12-27T12:01:04","slug":"bzoj-3190-jloi2013%e8%b5%9b%e8%bd%a6-%e5%8d%8a%e5%b9%b3%e9%9d%a2%e4%ba%a4","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=355","title":{"rendered":"bzoj  3190: [JLOI2013]\u8d5b\u8f66  &#8212; \u534a\u5e73\u9762\u4ea4"},"content":{"rendered":"<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69fdeefd61f59\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69fdeefd61f59\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#3190_JLOI2013%E8%B5%9B%E8%BD%A6\" title=\"3190: [JLOI2013]\u8d5b\u8f66\">3190: [JLOI2013]\u8d5b\u8f66<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Description\" title=\"Description\">Description<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Input\" title=\"Input\">Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Output\" title=\"Output\">Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Sample_Input\" title=\"Sample Input\">Sample Input<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Sample_Output\" title=\"Sample Output\">Sample Output<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#HINT\" title=\"HINT\">HINT<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/blog.kylelv.com\/?p=355\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"3190_JLOI2013%E8%B5%9B%E8%BD%A6\"><\/span>3190: [JLOI2013]\u8d5b\u8f66<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: center;\"><span class=\"green\">Time Limit:\u00a0<\/span>10 Sec\u00a0\u00a0<span class=\"green\">Memory Limit:\u00a0<\/span>128 MB<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Description\"><\/span>Description<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div><\/div>\n<div>\u8fd9\u91cc\u6709\u4e00\u8f86\u8d5b\u8f66\u6bd4\u8d5b\u6b63\u5728\u8fdb\u884c\uff0c\u8d5b\u573a\u4e0a\u4e00\u5171\u6709N\u8f86\u8f66\uff0c\u5206\u522b\u79f0\u4e3a\u4e2ag1\uff0cg2\u2026\u2026gn\u3002\u8d5b\u9053\u662f\u4e00\u6761\u65e0\u9650\u957f\u7684\u76f4\u7ebf\u3002\u6700\u521d\uff0cgi\u4f4d\u4e8e\u8ddd\u79bb\u8d77\u8dd1\u7ebf\u524d\u8fdbki\u7684\u4f4d\u7f6e\u3002\u6bd4\u8d5b\u5f00\u59cb\u540e\uff0c\u8f66\u8f86gi\u5c06\u4f1a\u4ee5vi\u5355\u4f4d\u6bcf\u79d2\u7684\u6052\u5b9a\u901f\u5ea6\u884c\u9a76\u3002\u5728\u8fd9\u4e2a\u6bd4\u8d5b\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u4e00\u8f86\u8d5b\u8f66\u66fe\u7ecf\u5904\u4e8e\u9886\u8dd1\u4f4d\u7f6e\u7684\u8bdd\uff08\u5373\u6ca1\u6709\u5176\u4ed6\u7684\u8d5b\u8f66\u8dd1\u5728\u4ed6\u7684\u524d\u9762\uff09\uff0c\u8fd9\u8f86\u8d5b\u8f66\u6700\u540e\u5c31\u53ef\u4ee5\u5f97\u5956\uff0c\u800c\u4e14\u6bd4\u8d5b\u8fc7\u7a0b\u4e2d\u4e0d\u7528\u62c5\u5fc3\u76f8\u649e\u7684\u95ee\u9898\u3002\u73b0\u5728\u7ed9\u51fa\u6240\u6709\u8d5b\u8f66\u7684\u8d77\u59cb\u4f4d\u7f6e\u548c\u901f\u5ea6\uff0c\u4f60\u7684\u4efb\u52a1\u5c31\u662f\u7b97\u51fa\u90a3\u4e9b\u8d5b\u8f66\u5c06\u4f1a\u5f97\u5956\u3002<\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Input\"><\/span>Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div>\u7b2c\u4e00\u884c\u6709\u4e00\u4e2a\u6b63\u6574\u6570N\u8868\u793a\u8d5b\u8f66\u7684\u4e2a\u6570\u3002<\/div>\n<div>\u63a5\u4e0b\u6765\u4e00\u884c\u7ed9\u51faN\u4e2a\u6574\u6570\uff0c\u6309\u987a\u5e8f\u7ed9\u51faN\u8f86\u8d5b\u8f66\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002<\/div>\n<div>\u518d\u63a5\u4e0b\u6765\u4e00\u884c\u7ed9\u51faN\u4e2a\u6574\u6570\uff0c\u6309\u987a\u5e8f\u7ed9\u51faN\u8f86\u8d5b\u8f66\u7684\u6052\u5b9a\u901f\u5ea6\u3002<\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<div><\/div>\n<div>\u8f93\u51fa\u5305\u62ec\u4e24\u884c\uff0c\u7b2c\u4e00\u884c\u4e3a\u83b7\u5956\u7684\u8d5b\u8f66\u4e2a\u6570\u3002<\/div>\n<div>\u7b2c\u4e8c\u884c\u6309\u4ece\u5c0f\u5230\u5927\u7684\u987a\u5e8f\u8f93\u51fa\u83b7\u5956\u8d5b\u8f66\u7684\u7f16\u53f7\uff0c\u7f16\u53f7\u4e4b\u95f4\u7528\u7a7a\u683c\u9694\u5f00\uff0c\u6ce8\u610f\u6700\u540e\u4e00\u4e2a\u7f16\u53f7\u540e\u9762\u4e0d\u8981\u52a0\u7a7a\u683c\u3002<\/div>\n<div><\/div>\n<div><\/div>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Input\"><\/span>Sample Input<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\"><span class=\"sampledata\">4<br \/>\n1 1 0 0<br \/>\n15 16 10 20<\/span><\/span>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Sample_Output\"><\/span>Sample Output<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\"><span class=\"sampledata\"><span class=\"sampledata\">3<br \/>\n1 2 4<\/span><\/span>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div class=\"content\">\n<p>\u5bf9\u4e8e100%\u7684\u6570\u636eN&lt;=10000, 0&lt;=ki&lt;=10^9, 0&lt;=vi&lt;=10^9<\/p>\n<p>2016.1.17\u65b0\u52a0\u6570\u636e\u4e00\u7ec4 By Nano_ape<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u534a\u5e73\u9762\u4ea4\u5165\u95e8\u9898<\/p>\n<p>\u5c31\u662f\u5224\u4e00\u4e0b\u4ea4\u70b9\u4f4d\u7f6e\u5c31\u597d\u4e86<\/p>\n<pre class=\"lang:c++ decode:true \">#include&lt;map&gt;\r\n#include&lt;cmath&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;iostream&gt;\r\n#include&lt;algorithm&gt;\r\nusing namespace std;\r\n#define inf 1000000007\r\n#define ll long long\r\n#define N 10010\r\ninline int rd()\r\n{\r\n\tint x=0,f=1;char ch=getchar();\r\n\twhile(ch&lt;'0'||ch&gt;'9'){if(ch=='-')f=-1;ch=getchar();}\r\n\twhile(ch&gt;='0'&amp;&amp;ch&lt;='9'){x=x*10+ch-'0';ch=getchar();}\r\n\treturn x*f;\r\n}\r\nstruct mp{int x,v,d;}a[N],q[N];\r\nbool operator &lt;(mp a,mp b){return a.v==b.v?a.x&lt;b.x:a.v&lt;b.v;}\r\nint n,ans[N],tot;\r\ninline double cck(mp a,mp b){return (a.x-b.x)*1.0\/(b.v-a.v);} \r\ninline bool ck(mp a,mp b,mp c){return cck(a,b)&gt;cck(a,c);}\r\nint main()\r\n{\r\n\tn=rd();\r\n\tfor(int i=1;i&lt;=n;i++) a[i].x=rd();\r\n\tfor(int i=1;i&lt;=n;i++) a[i].v=rd();\r\n\tfor(int i=1;i&lt;=n;i++) a[i].d=i;\r\n\tsort(a+1,a+n+1);tot=1;\r\n\tfor(int i=2;i&lt;=n;i++)\r\n\t{\r\n\t\tif(a[i].v!=a[i-1].v||(a[i].v==a[i-1].v&amp;&amp;a[i].x==a[i-1].x)) tot++;\r\n\t\ta[tot]=a[i];\r\n\t}\r\n\tn=tot;tot=0;\r\n\tfor(int i=1;i&lt;=n;i++)\r\n\t{\r\n\t\twhile(tot&amp;&amp;q[tot].x&lt;a[i].x) tot--;\r\n\t\twhile(tot&gt;1&amp;&amp;ck(q[tot-1],q[tot],a[i])) tot--;\r\n\t\tq[++tot]=a[i];\r\n\t\tans[tot]=a[i].d;\r\n\t}\r\n\tprintf(\"%d\\n\",tot);\r\n\tsort(ans+1,ans+tot+1);\r\n\tfor(int i=1;i&lt;=tot;i++) printf(\"%d%c\",ans[i],\" \\n\"[i==tot]);\r\n\treturn 0;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 3190: [JLOI2013]\u8d5b\u8f66 Time Limit:\u00a010 Sec\u00a0\u00a0Memory Li [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[31],"class_list":["post-355","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-31"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=355"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/355\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}