花束布置问题 C程序 动态规划
#include
iNTi,j,k,m,n,p,s,r,t;
intf[110][110],a[110][110];
intmain()
scanf("%d%d\n",&n,&m);
for(i=1;i<=n;i++)
fOr(intj=1;j<=m;j++)
scanf("%d",&a[i][j]);
scanf("\n");
memset(f,0,sizeof(f));
for(i=1;i<=n+1;i++)f[i][m+1]=-10000;
for(i=m;i>0;i--)
if(f[n][i+1]>a[n][i])f[n][i]=f[n][i+1];
elsef[n][i]=a[n][i];
for(i=n-1;i>0;i--)
for(j=m;j>0;j--)
f[i][j]=f[i][j+1];
if(f[i][j]
printf("%d\n",f[1][1]);
for(i=1;i<=n;i++)
while(f[i][j]==f[i][p])j++;
printf("%d",j-1);
return0;
本回答由提问者推荐