ACboy needs your help HDU - 1712

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ACboy needs your help HDU - 1712相关的知识,希望对你有一定的参考价值。

ACboy needs your help HDU - 1712

ans[i][j]表示前i门课共花j时间最大收益。对于第i门课,可以花k(0<=k<=j)时间,那么之前i-1门课共花j-k时间。

错误记录:

21行一个0写成1

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 int a[101][101],ans[101][101];
 6 int n,m,anss;
 7 int main()
 8 {
 9     int i,j,k;
10     scanf("%d%d",&n,&m);
11     while(n!=0&&m!=0)
12     {
13         for(i=1;i<=n;i++)
14             for(j=1;j<=m;j++)
15                 scanf("%d",&a[i][j]);
16         memset(ans,0,sizeof(ans));
17         anss=0;
18         for(i=1;i<=n;i++)
19             for(j=1;j<=m;j++)
20             {
21                 for(k=0;k<=j;k++)
22                     ans[i][j]=max(ans[i][j],ans[i-1][j-k]+a[i][k]);
23                 anss=max(anss,ans[i][j]);
24             }
25         printf("%d\n",anss);
26         scanf("%d%d",&n,&m);
27     }
28     return 0;
29 }

以上是关于ACboy needs your help HDU - 1712的主要内容,如果未能解决你的问题,请参考以下文章

HDU 1702 ACboy needs your help again!

Hdu 1702 ACboy needs your help again!

hdu1702 ACboy needs your help again!

hdu 1712 ACboy needs your help(分组背包入门)

ACboy needs your help HDU - 1712

ACboy needs your help HDU - 1712