标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5022 Accepted Submission(s): 2714
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; int a[200][200]; int f[1000]; int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF){ if(n==0&&m==0) break; memset(f,0,sizeof(f)); memset(a,0,sizeof(a)); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) scanf("%d",&a[i][j]); } for(int i=1;i<=n;i++){ for(int j=m;j>=0;j--){ for(int k=1;k<=j;k++) f[j]=max(f[j],f[j-k]+a[i][k]); } } printf("%d\n",f[m]); } return 0; }
hdu1712 分组背包 ACboy needs your help
标签:
原文地址:http://www.cnblogs.com/13224ACMer/p/4676274.html