The problem test instructions a bit of a hole, feeling particularly vague,
I began to have a little understanding, that is, the reimbursement of the entire cheque is reimbursed, but also I am stupid, no common sense
Another point is that the total amount of a single cheque is not more than 1000, each cheque in the total amount of not more than 600, I began to think that the problem is the data will give, did not expect to own judgment
And do not meet the conditions of the cheque to go directly to the 、--、 can only blame themselves to do less, nothing or a good brush, even if others give up I do not allow themselves to give up
The input data for this question are all 2 decimal places and can be processed directly into integers
And then it's the bare 01 backpack.
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <algorithm>5 using namespacestd;6 Const intqq=5000000+ -;7 intDP[QQ];8 intP[QQ];9 intMain ()Ten { One Doubletot; A intN; - while(~SCANF ("%lf%d", &tot,&n) &&N) { -Memset (DP,0,sizeof(DP)); the intSum= (int) (tot* -); - //printf ("%d\n", sum); - intCount=0, M; - Doublex; + Chars; - for(intI=0; i<n;++i) { +scanf"%d",&m); A intA,b,c,flag; atA=b=c=0; -flag=1; - for(intj=0; j<m;++j) { -scanf"%*C%C%*C%LF",&s,&x); - intY= (int) (x* -); - if(s=='A') a+=y; in Else if(s=='B') b+=y; - Else if(s=='C') c+=y; to Elseflag=0; + } - if(A+b+c<=1e5 && a<=60000&& b<=60000&& c<=60000&&flag) thep[count++]=a+b+C; * } $ for(intI=0; i<count;++i)Panax Notoginseng for(intj=sum;j>=p[i];--j) -Dp[j]=max (dp[j],dp[j-p[i]]+p[i]); theprintf"%.2lf\n", dp[sum]*1.0/ -); + } A return 0; the}
HDU 1864 01 Backpack,