{"id":269,"date":"2016-11-24T14:31:44","date_gmt":"2016-11-24T06:31:44","guid":{"rendered":"http:\/\/kylelv.com\/?p=269"},"modified":"2017-12-13T13:20:29","modified_gmt":"2017-12-13T05:20:29","slug":"bzoj-3399-usaco2009-marsand-castle%e5%9f%8e%e5%a0%a1","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=269","title":{"rendered":"bzoj 3399: [Usaco2009 Mar]Sand Castle\u57ce\u5821"},"content":{"rendered":"<p><center><\/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-69fdef7562fc9\" 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-69fdef7562fc9\"  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=269\/#3399_Usaco2009_MarSand_Castle%E5%9F%8E%E5%A0%A1\" title=\"3399: [Usaco2009 Mar]Sand Castle\u57ce\u5821\">3399: [Usaco2009 Mar]Sand Castle\u57ce\u5821<\/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=269\/#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=269\/#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=269\/#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=269\/#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=269\/#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=269\/#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=269\/#Source\" title=\"Source\">Source<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"3399_Usaco2009_MarSand_Castle%E5%9F%8E%E5%A0%A1\"><\/span>3399: [Usaco2009 Mar]Sand Castle\u57ce\u5821<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Time Limit:\u00a03 Sec\u00a0\u00a0Memory Limit:\u00a0128 MB<\/center><\/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>\u7ea6\u7ff0\u7528\u6c99\u5b50\u5efa\u4e86\u4e00\u5ea7\u57ce\u5821\uff0e\u6b63\u5982\u6240\u6709\u57ce\u5821\u7684\u57ce\u5899\uff0c\u8fd9\u57ce\u5899\u4e5f\u6709\u8bb8\u591a\u67aa\u773c\uff0c\u4e24\u4e2a\u76f8\u90bb\u67aa\u773c\u4e2d\u95f4\u90a3\u90e8\u5206\u53eb\u4f5c\u201c\u57ce\u9f7f\u201d\uff0e\u00a0\u00a0\u00a0\u00a0\u57ce\u5899\u4e0a\u4e00\u5171\u6709N(1\u2264N\u226425000)\u4e2a\u57ce\u9f7f\uff0c\u6bcf\u4e00\u4e2a\u90fd\u6709\u4e00\u4e2a\u9ad8\u5ea6Mi.(1\u2264\u5c2c\u2264100000)\uff0e\u73b0\u5728\u7ea6\u7ff0\u60f3\u628a\u57ce\u9f7f\u7684\u9ad8\u5ea6\u8c03\u6210\u67d0\u79cd\u987a\u5e8f\u4e0b\u7684Bi\uff0cB2\uff0c\u2026\uff0cBN(I\u2264Bi\u2264100000).\u00a0-\u4e2a\u57ce\u9f7f\u6bcf\u63d0\u9ad8\u4e00\u4e2a\u5355\u4f4d\u7684\u9ad8\u5ea6\uff0c\u7ea6\u7ff0\u9700\u8981X(I\u2264X\u2264100)\u5143\uff1b\u6bcf\u964d\u4f4e\u4e00\u4e2a\u5355\u4f4d\u7684\u9ad8\u5ea6\uff0c\u7ea6\u7ff0\u9700\u8981Y(1\u2264y\u2264100)\u5143\uff0e\u00a0\u00a0\u00a0\u00a0\u95ee\u7ea6\u7ff0\u6700\u5c11\u53ef\u7528\u591a\u5c11\u94b1\u8fbe\u5230\u76ee\u7684\uff0e\u6570\u636e\u4fdd\u8bc1\u7b54\u6848\u4e0d\u8d85\u8fc72^32\uff0e<\/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><\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u7b2c1\u884c\u8f93\u51653\u4e2a\u6574\u6570N\uff0cX\uff0cY.<\/div>\n<div>\u00a0\u00a0\u00a0\u00a0\u7b2c2\u5230N+1\u884c\u6bcf\u884c\u8f93\u5165\u4e24\u4e2a\u6574\u6570Mi\u548cBi\uff0e<\/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>\u00a0\u00a0\u00a0\u00a0\u6700\u5c11\u82b1\u8d39\uff0e<\/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\">3 6 5<br \/>\n3 1<br \/>\n1 2<br \/>\n1 2<\/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\">11<\/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>&nbsp;<\/p>\n<p>\u7b2c1\u4e2a\u57ce\u9f7f\u964d\u4f4e1\uff0c\u7b2c2\u4e2a\u57ce\u9f7f\u63d0\u9ad81<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Source\"><\/span>Source<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:c++ decode:true \">#include&lt;cstdio&gt;\r\n#include&lt;algorithm&gt;\r\n#define N 25001\r\nusing namespace std;\r\nint n,m[N],b[N],x,y,ans;\r\ninline int f(int a,int z){return a&gt;z?(a-z)*y:(z-a)*x;}\r\nint main()\r\n{\r\n    scanf(\"%d%d%d\",&amp;n,&amp;x,&amp;y);\r\n    for(int i=0;i&lt;n;i++) scanf(\"%d%d\",&amp;m[i],&amp;b[i]);\r\n    sort(m,m+n);sort(b,b+n);\r\n    for(int i=0;i&lt;n;i++) ans+=f(m[i],b[i]);\r\n    printf(\"%d\",ans);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3399: [Usaco2009 Mar]Sand Castle\u57ce\u5821 Time Limit:\u00a03 Sec\u00a0\u00a0M [&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":[6],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-6"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/269","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=269"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/269\/revisions\/270"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}