2014.txt

来自「北大ACM题目例程 详细的解答过程 程序实现 算法分析」· 文本 代码 · 共 60 行

TXT
60
字号


#include<stdio.h>
#include<string.h>
#define debug 0


#define NMAX 1026
int a[NMAX][NMAX];
int main()
{

#if debug 	
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
  	int x,y;
  	int maxx;
  	int maxy;
  	int wide;
  	int a,b;
  	scanf("%d",&wide);
  	while(wide)
  	{
  		a=0;b=0;
  		maxy=0;
  		maxx=0;
  		scanf("%d%d",&x,&y);
  		while(x!=-1)
  		{
  			if(a+x<=wide)
  			{
  				a+=x;
  				if(a>maxx)
  					maxx=a;
  				if(b+y>maxy)
  					maxy=b+y;
  			}
  			else
  			{
  				a=0;
  				b=maxy;
  				continue;
  			}
	  		scanf("%d%d",&x,&y);
  		}
  		printf("%d x %d\n",maxx,maxy);
  		
  		scanf("%d",&wide);
  	}
  		  	
  	
#if debug
	fclose(stdin);
	fclose(stdout);
#endif
	return 1;
}

⌨️ 快捷键说明

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