⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1685.cpp

📁 哈尔滨工业大学ACM 竞赛网上在线试题集锦的源代码
💻 CPP
字号:
/*  This Code is Submitted by wywcgs for Problem 1685 on 2005-03-24 at 07:12:02 */ 
#include <stdio.h>

int main()
{
    int maxWid, totalLen, totalWid, recLen, recWid;
    int curLen, curWid;
    
    while(scanf("%d", &maxWid) == 1){
        if(maxWid == 0){
            return 0;
        }else{
            totalLen = 0;
            totalWid = 0;
            curLen = 0;
            curWid = 0;
            while(scanf("%d %d", &recWid, &recLen) == 2){
                if((recLen == -1) && (recWid == -1)){
                    if(totalWid < curWid){
                        totalWid = curWid;
                    }
                    totalLen += curLen;
                    break;
                }else{
                    if(recWid + curWid <= maxWid){
                        curWid += recWid;
                        if(curLen < recLen){
                            curLen = recLen;
                        }
                    }else{
                        if(totalWid < curWid){
                            totalWid = curWid;
                        }
                        curWid = recWid;
                        totalLen += curLen;
                        curLen = recLen;
                    }
                }
            }    
            printf("%d x %d\n", totalWid, totalLen);
        }
    }
    
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -