标签:des style blog http color java os io
解题报告
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define inf 99999999 using namespace std; int v,w[35],d[4],dw1,sum,dp[31*1000*100]; int main() { double Q,dw; int n,i,j,m,t; char c; while(~scanf("%lf %d",&Q,&n)) { m=0; v=(int)(Q*100); memset(dp,0,sizeof(dp)); memset(w,0,sizeof(w)); if(!n)break; for(i=1; i<=n; i++) { scanf("%d",&t); sum=0; int f=0; memset(d,0,sizeof(d)); for(j=1; j<=t; j++) { scanf(" %c:%lf",&c,&dw); dw1=(int)(dw*100); if(c>='A'&&c<='C') { d[c-'A']+=dw1; sum+=dw1; } else f=1; } if(!f&&sum<=100000&&d[0]<=60000&&d[1]<=60000&&d[2]<=60000) { w[m++]=sum; } } for(i=0; i<m; i++) { for(j=v; j>=w[i]; j--) { dp[j]=max(dp[j],dp[j-w[i]]+w[i]); } } printf("%.2lf\n",dp[v]/100.0); } }
200.00 3 2 A:23.50 B:100.00 1 C:650.00 3 A:59.99 A:120.00 X:10.00 1200.00 2 2 B:600.00 A:400.00 1 C:200.50 1200.50 3 2 B:600.00 A:400.00 1 C:200.50 1 A:100.00 100.00 0
HDU1864_最大报销额(背包/01背包),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://blog.csdn.net/juncoder/article/details/38669833