{"id":1043,"date":"2014-10-19T22:12:16","date_gmt":"2014-10-19T14:12:16","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=1043"},"modified":"2014-10-19T22:12:16","modified_gmt":"2014-10-19T14:12:16","slug":"bzoj-1597-usaco2008-mar%e5%9c%9f%e5%9c%b0%e8%b4%ad%e4%b9%b0","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/bzoj-1597-usaco2008-mar%e5%9c%9f%e5%9c%b0%e8%b4%ad%e4%b9%b0\/","title":{"rendered":"BZOJ 1597. [Usaco2008 Mar]\u571f\u5730\u8d2d\u4e70"},"content":{"rendered":"<p><!--more--><\/p>\n<h3>Brief description: <\/h3>\n<p>\u7565\u3002\uff09<\/p>\n<h3>Analysis: <\/h3>\n<p><a href=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2014\/10\/11.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1044\" data-permalink=\"https:\/\/www.shuizilong.com\/house\/archives\/bzoj-1597-usaco2008-mar%e5%9c%9f%e5%9c%b0%e8%b4%ad%e4%b9%b0\/1-11\/\" data-orig-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2014\/10\/11.png\" data-orig-size=\"275,219\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2014\/10\/11.png\" data-large-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2014\/10\/11.png\" src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2014\/10\/11.png\" alt=\"1\" width=\"275\" height=\"219\" class=\"aligncenter size-full wp-image-1044\" \/><\/a><\/p>\n<pre class=\"brush: cpp; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\nconst int N = int(5e4) + 9;\r\n\r\nVII II, I; LL f&#x5B;N]; int q&#x5B;N], cz, op;\r\nint n;\r\n\r\n#define k I&#x5B;i].fi\r\n#define x(j) I&#x5B;j+1].se\r\n#define y(j) f&#x5B;j]\r\n#define eval(j) ((LL)k*x(j)+y(j))\r\n\r\nLL det(LL x1, LL y1, LL x2, LL y2){\r\n    return x1*y2 - x2*y1;\r\n}\r\n\r\nint dett(int p0, int p1, int p2){\r\n    LL t = det(x(p1)-x(p0), y(p1)-y(p0), x(p2)-x(p0), y(p2)-y(p0));\r\n    return t &lt; 0 ? -1 : t &gt; 0;\r\n}\r\n\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    II.resize(RD(n)); REP(i, n) RD(II&#x5B;i].fi, II&#x5B;i].se);\r\n\r\n    SRT(II); II.PB(MP(INF, 0)); I.PB(MP(0, INF)); REP(i, n){\r\n        while (I.back().se &lt;= II&#x5B;i].se) I.pop_back();\r\n        I.PB(II&#x5B;i]);\r\n    }\r\n\r\n    \/*n = SZ(I)-1; REP_1(i, n){\r\n        f&#x5B;i] = INFF;\r\n        REP(j, i) checkMin(f&#x5B;i], (LL)I&#x5B;i].fi*I&#x5B;j+1].se + f&#x5B;j]);\r\n        cout &lt;&lt; f&#x5B;i] &lt;&lt; endl;\r\n    }*\/\r\n\r\n    n = SZ(I)-1; cz = 0, op = 0; REP_1(i, n){\r\n        while (cz &lt; op &amp;&amp; eval(q&#x5B;cz]) &gt;= eval(q&#x5B;cz+1])) ++cz; f&#x5B;i] = eval(q&#x5B;cz]);\r\n        while (cz &lt; op &amp;&amp; dett(q&#x5B;op-1], q&#x5B;op], i) &gt; 0) --op; q&#x5B;++op] = i;\r\n        \/\/cout &lt;&lt; f&#x5B;i] &lt;&lt; endl;\r\n    }\r\n\r\n    cout &lt;&lt; f&#x5B;n] &lt;&lt; endl;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-1043","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-gP","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=1043"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1043\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}