- 盖房子
- 2015-12-23 20:08:33 @
#include<stdio.h>
#include<string.h>
int f[1002][1002];
int min(int a,int b)
{
if(a>b) return b;
else return a;
}
int main()
{
memset(f,0,sizeof(f));
int n,m,j,i,max=-1;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++)
for(j=1;j<=m;j++)
{scanf("%d",&f[i][j]);
f[i][j]+=min(min(f[i-1][j],f[i-1][j-1]),f[i][j-1]);
if(f[i][j]>max) max=f[i][j];
}
printf("%d\n",max);
return 0;
}
如何优化是内存占用变小呢
1 条评论
-
iceboy LV 8 MOD @ 2015-12-24 21:12:04
int f[2][1002];
- 1