Compete

I can't fall down before I die

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  11 Posts :: 3 Stories :: 2 Comments :: 0 Trackbacks

常用链接

留言簿(2)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

#include<iostream>
using namespace std;
int main()
{
    
int lastw,lasth,nextw,nexth,inh,inw;
    
int curh,curw;
    
int wid;
    
while(cin>>wid)
    
{
        
if(wid==0)
            
break;
        lastw
=0;
        lasth
=0;
        nextw
=0;
        nexth
=0;
        curh
=0;
        curw
=0;
        
while(cin>>inw>>inh)
        
{
            
if(inw==-1 && inh==-1)
                
break;
            
if(curw+inw<=wid)
            
{
                curw
+=inw;
                
if(nextw<curw)
                    nextw
=curw;
                
if(curw>lastw)
                    lastw
=curw;
                curh
=lasth+inh;
                
if(curh>nexth)
                    nexth
=curh;
            }

            
else
            
{
                lasth
=nexth;

                lastw
=nextw;
                curh
=lasth+inh;
                nexth
=curh;
                curw
=inw;
                
if(curw>nextw)
                    nextw
=curw;
            }

        }

        cout
<<nextw<<" x "<<nexth<<endl;
    }

    
return 0;
}

posted on 2010-05-27 18:02 丁立洋 阅读(269) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理