|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2013-5-2 13:22:47
|
显示全部楼层
if(freopen(file_in_name,"r",stdin)==NULL)
{
fprintf(stderr, "open %s error\n",file_in_name);
return 1;
}
scanf("%d",&n);
scanf("%d",&m);
scanf("%d",&k);
memset(a,0x00,sizeof(a));
for(i=0;i<k;i++)
{
scanf("%d",&x);
scanf("%d",&y);
scanf("%d",&z);
a[x][y]=z;
}
memset(b,0x00,sizeof(b));
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
b[i][j]=max(b[i-1][j],b[i][j-1])+a[i][j];
}
if(freopen(file_out_name,"w",stdout)==NULL)
{
fprintf(stderr, "open %s error\n",file_out_name);
return 1;
}
printf("%d",b[n][m]);
|
|