{"id":140,"date":"2010-03-05T20:58:00","date_gmt":"2010-03-05T12:58:00","guid":{"rendered":"http:\/\/localhost\/?p=140"},"modified":"2010-03-05T20:58:00","modified_gmt":"2010-03-05T12:58:00","slug":"sgu_478_excursion","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=140","title":{"rendered":"SGU 478. Excursion"},"content":{"rendered":"<p> <a href=\"http:\/\/acm.sgu.ru\/problem.php?contest=0&amp;problem=478\" target=\"_blank\">acm.sgu.ru\/problem.php<\/a><br \/>\u6211\u66f4\u660e\u767d\u4e86\u4e00\u4e2a\u4e8b\u5b9e\uff0c\u5c31\u662f\u6211\u662f\u4e00\u4e2a\u6c99\u8336\u56e7\u3002\u3002<br \/>\u8fd9\u79cd\u9898\u76ee\u6211\u5728\u5f53\u65f6\u6bd4\u8d5b\u7684\u65f6\u5019\u5c45\u7136\u7528\u5e26\u4e0a\u4e0b\u754c\u7684\u6700\u5927\u6d41\u53bb\u505a\u3002\u7ed3\u679c\u60b2\u5267\u6b7b\u3002\u3002<br \/>\u5b9e\u9645\u4e0a\u7b80\u5355\u7684\u8d2a\u5fc3\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u5982\u679c\u4eba\u53d8\u591a\u4e86\u8ba9boy\u56de\u6765\u5426\u5219\u8ba9girl\u51fa\u53bb\u3002\u3002<br \/>Code\uff1a<br \/>#include&lt;cstdio&gt;<br \/>#include&lt;iostream&gt;<br \/>#include&lt;algorithm&gt;<br \/>#include&lt;string&gt;<br \/>#include&lt;vector&gt;<br \/>#include&lt;utility&gt;<br \/>#define rep(i,n) for(int i=0;i&lt;n;i++)<br \/>using namespace std;<br \/>typedef pair&lt;int,int&gt; pi;<br \/>const int inf=~0U&gt;&gt;1;<br \/>int main()<br \/>{<br \/>    freopen(&quot;in&quot;,&quot;r&quot;,stdin);<br \/>    int b,g,n;<br \/>    cin&gt;&gt;b&gt;&gt;g&gt;&gt;n;<br \/>    vector&lt;pi&gt; A;<br \/>    int now=g;<br \/>    rep(i,n)<br \/>    {<br \/>        int x;cin&gt;&gt;x;<br \/>        if(x&gt;=now)<br \/>        {<br \/>            b-=x-now;<br \/>            if(b&lt;0) break;<br \/>            A.push_back(pi(x-now,0));<br \/>            now=x;<br \/>        }<br \/>        else<br \/>        {<br \/>            g-=now-x;<br \/>            if(g&lt;0) break;<br \/>            A.push_back(pi(0,now-x));<br \/>            now=x;<br \/>        }<br \/>    }<br \/>    if(A.size()&lt;n)<br \/>        cout&lt;&lt;&quot;ERROR&quot;&lt;&lt;endl;<br \/>    else<br \/>    {<br \/>        rep(i,n)<br \/>            cout&lt;&lt;A[i].first&lt;&lt;&quot; &quot;&lt;&lt;A[i].second&lt;&lt;endl;<br \/>    }<br \/>} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>acm.sgu.ru\/problem.php\u6211\u66f4\u660e\u767d\u4e86\u4e00\u4e2a\u4e8b\u5b9e\uff0c\u5c31\u662f\u6211\u662f\u4e00\u4e2a\u6c99\u8336\u56e7\u3002\u3002\u8fd9\u79cd\u9898\u76ee\u6211\u5728\u5f53\u65f6\u6bd4\u8d5b\u7684\u65f6\u5019\u5c45\u7136\u7528\u5e26\u4e0a\u4e0b\u754c\u7684\u6700\u5927\u6d41\u53bb\u505a\u3002\u7ed3\u679c\u60b2\u5267\u6b7b\u3002\u3002\u5b9e\u9645\u4e0a\u7b80\u5355\u7684\u8d2a\u5fc3\u5c31\u53ef\u4ee5\u4e86\u3002\u3002\u5982\u679c\u4eba\u53d8\u591a\u4e86\u8ba9boy\u56de\u6765\u5426\u5219\u8ba9girl\u51fa\u53bb\u3002\u3002Code\uff1a#include&lt;cstdio&gt;#include&lt;iostream&gt;#include&lt;algorithm&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;utility&gt;#define rep(i,n) for(int i=0;i&lt;n;i++)using namespace std;typedef pair&lt;int,int&gt; pi;const int inf=~0U&gt;&gt;1;int main(){ freopen(&quot;in&quot;,&quot;r&quot;,stdin); int b,g,n; cin&gt;&gt;b&gt;&gt;g&gt;&gt;n; vector&lt;pi&gt; A; int now=g; rep(i,n) { int x;cin&gt;&gt;x; if(x&gt;=now) { b-=x-now; if(b&lt;0) break; A.push_back(pi(x-now,0)); now=x; } else { g-=now-x; if(g&lt;0) break; A.push_back(pi(0,now-x)); now=x; } } if(A.size()&lt;n) cout&lt;&lt;&quot;ERROR&quot;&lt;&lt;endl; else { rep(i,n) cout&lt;&lt;A[i].first&lt;&lt;&quot; &quot;&lt;&lt;A[i].second&lt;&lt;endl; }}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/140"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}