poj(2063)多次完全背包
2013-05-10 21:02
274 查看
开始时觉得开二维dp[i]p[j]表示第i年j投资所得到的最大价值,后来觉得每一年都可以得到一个总投资数,那么进行多次完全背包,每次更新的是其sum总值,无奈数组开小了,WA了好多次。。。。。 不过这个题目还是简单的 #include <iostream> #include <cstdio> #include <string.h> using namespace std; int dp[100110];//竟然是数组太小了,WA了好多次 struct node { int cost; int value; }s[1500]; int main() { int t,i,d,sum,year,maxf,j,k,l,sy; scanf("%d",&t); while(t--) { memset(dp,0,sizeof(dp)); scanf("%d%d%d",&sum,&year,&d); sy=sum/1000; for (i=1;i<=d;++i) { scanf("%d%d",&s[i].cost,&s[i].value); s[i].cost=s[i].cost/1000; } for (i=1;i<=year;++i) { memset(dp,0,sizeof(dp)); maxf=-1; for (j=1;j<=d;++j) for (k=s[j].cost;k<=sy;++k) { dp[k]=max(dp[k],dp[k-s[j].cost]+s[j].value); } sum=sum+dp[sy]; sy=sum/1000; } printf ("%d\n",sum); } return 0; }
相关文章推荐
- poj 2063 多次完全背包
- poj 2063 Investment 多次完全背包
- 完全背包——POJ 2063
- POJ 2063 Investment 完全背包
- poj 2063 基础完全背包
- POJ 2063 - Investment(完全背包)
- POJ 2063 Investment 完全背包
- POJ 2063 Investment / 体积变大的完全背包
- POJ 2063 Investment(完全背包)
- poj 2063 完全背包
- POJ-2063--Investment (完全背包)
- poj 2063 Investment 完全背包
- POJ 2063 Investment(完全背包问题)
- poj 2063 Investment 完全背包问题
- Investment 完全背包 POJ 2063
- POJ 2063 Investment 完全背包问题
- poj 2063 完全背包问题
- poj 2063& zoj 2224 Investment (多次完全背包)
- 完全背包 POJ - 2063
- POJ-2063 完全背包