{"id":264,"date":"2016-11-23T14:32:20","date_gmt":"2016-11-23T06:32:20","guid":{"rendered":"http:\/\/kylelv.com\/?p=264"},"modified":"2017-12-13T13:16:08","modified_gmt":"2017-12-13T05:16:08","slug":"bzoj-1650-usaco2006-decriver-hopscotch-%e8%b7%b3%e7%9f%b3%e5%ad%90","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=264","title":{"rendered":"bzoj 1650: [Usaco2006 Dec]River Hopscotch \u8df3\u77f3\u5b50"},"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-69fdef1b3338c\" 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-69fdef1b3338c\"  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=264\/#1650_Usaco2006_DecRiver_Hopscotch_%E8%B7%B3%E7%9F%B3%E5%AD%90\" title=\"1650: [Usaco2006 Dec]River Hopscotch \u8df3\u77f3\u5b50\">1650: [Usaco2006 Dec]River Hopscotch \u8df3\u77f3\u5b50<\/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=264\/#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=264\/#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=264\/#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=264\/#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=264\/#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=264\/#HINT\" title=\"HINT\">HINT<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"1650_Usaco2006_DecRiver_Hopscotch_%E8%B7%B3%E7%9F%B3%E5%AD%90\"><\/span>1650: [Usaco2006 Dec]River Hopscotch \u8df3\u77f3\u5b50<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span class=\"green\">Time Limit:\u00a05 Sec\u00a0\u00a0Memory Limit:\u00a064 MB<\/span><\/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<p>Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and another rock at the end, L units away from the start (1 &lt;= L &lt;= 1,000,000,000). Along the river between the starting and ending rocks, N (0 &lt;= N &lt;= 50,000) more rocks appear, each at an integral distance Di from the start (0 &lt; Di &lt; L). To play the game, each cow in turn starts at the starting rock and tries to reach the finish at the ending rock, jumping only from rock to rock. Of course, less agile cows never make it to the final rock, ending up instead in the river. Farmer John is proud of his cows and watches this event each year. But as time goes by, he tires of watching the timid cows of the other farmers limp across the short distances between rocks placed too closely together. He plans to remove several rocks in order to increase the shortest distance a cow will have to jump to reach the end. He knows he cannot remove the starting and ending rocks, but he calculates that he has enough resources to remove up to M rocks (0 &lt;= M &lt;= N). FJ wants to know exactly how much he can increase the shortest distance *before* he starts removing the rocks. Help Farmer John determine the greatest possible shortest distance a cow has to jump after removing the optimal set of M rocks.<\/p>\n<p>\u6570\u8f74\u4e0a\u6709n\u4e2a\u77f3\u5b50\uff0c\u7b2ci\u4e2a\u77f3\u5934\u7684\u5750\u6807\u4e3aDi\uff0c\u73b0\u5728\u8981\u4ece0\u8df3\u5230L\uff0c\u6bcf\u6b21\u6761\u90fd\u4ece\u4e00\u4e2a\u77f3\u5b50\u8df3\u5230\u76f8\u90bb\u7684\u4e0b\u4e00\u4e2a\u77f3\u5b50\u3002\u73b0\u5728FJ\u5141\u8bb8\u4f60\u79fb\u8d70M\u4e2a\u77f3\u5b50\uff0c\u95ee\u79fb\u8d70\u8fd9M\u4e2a\u77f3\u5b50\u540e\uff0c\u76f8\u90bb\u4e24\u4e2a\u77f3\u5b50\u8ddd\u79bb\u7684\u6700\u5c0f\u503c\u7684\u6700\u5927\u503c\u662f\u591a\u5c11\u3002<\/p>\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<p>* Line 1: Three space-separated integers: L, N, and M * Lines 2..N+1: Each line contains a single integer indicating how far some rock is away from the starting rock. No two rocks share the same position.<\/p>\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<p>* Line 1: A single integer that is the maximum of the shortest distance a cow has to jump after removing M rocks<\/p>\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\">25 5 2<br \/>\n2<br \/>\n14<br \/>\n11<br \/>\n21<br \/>\n17<\/p>\n<p>5 rocks at distances 2, 11, 14, 17, and 21. Starting rock at position<br \/>\n0, finishing rock at position 25.<br \/>\n<\/span><\/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\">4<br \/>\n<\/span><\/div>\n<h2><span class=\"ez-toc-section\" id=\"HINT\"><\/span>HINT<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\nusing namespace std;\r\nint n,m,ll,d[50010],l=1,r;\r\nbool f(int a)\r\n{\r\n    int k=0,ji=0;\r\n    for(int i=0;i&lt;=n;i++) d[i]-ji&lt;a?k++:ji=d[i];\r\n    return k&lt;=m?1:0;\r\n}\r\nint main()\r\n{\r\n    scanf(\"%d%d%d\",&amp;ll,&amp;n,&amp;m);\r\n    for(int i=0;i&lt;n;i++) scanf(\"%d\",&amp;d[i]);\r\n    sort(d,d+n);\r\n    d[n]=r=ll;\r\n    while(l&lt;r)\r\n    {\r\n        int mid=(l+r+1)&gt;&gt;1;\r\n        f(mid)?l=mid:r=mid-1;\r\n    }\r\n    printf(\"%d\\n\",l);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<div class=\"content\">\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1650: [Usaco2006 Dec]River Hopscotch \u8df3\u77f3\u5b50 Time Limit:\u00a05  [&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":[11],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-bzoj","tag-11"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/264","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=264"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/264\/revisions\/265"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}