标签:des style blog http java color
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 15792 Accepted Submission(s): 4561
#include <stdio.h> #include <string.h> #include <algorithm> #define N 3000500 using namespace std; int dp[N],cost[100],a[4]; char s[20]; int main() { double m; int V,n,i,j,num,wei; while(~scanf("%lf %d",&m,&n),n) { wei = 0; V = (int)(m*100.0); int cout = 0,ok ,ans; while(n--) { scanf("%d",&num); ok = 0,a[0] = a[1] = a[2] = 0; while(num--) { getchar(); scanf("%c%c%lf",&s[0],&s[1],&m); if(s[0]==‘A‘||s[0] == ‘B‘ || s[0] ==‘C‘){ ans = (int)(m*100.0); if(s[0] == ‘A‘) a[0]+=ans; else if(s[0] == ‘B‘) a[1]+=ans; else a[2]+=ans; }else ok = 1; } if(!ok&& a[1]+a[2]+a[0]<=100000&&a[0]<=60000&&a[1]<=60000&&a[2]<=60000) {cost[cout++] = a[0]+a[1]+a[2];wei+=a[0]+a[1]+a[2];} } if(V>wei) V = wei; memset(dp,0,sizeof(dp)); for(i = 0 ; i < cout ; i++) { for(j = V ;j>=cost[i] ; j--) dp[j] = max(dp[j],dp[j-cost[i]]+cost[i]); } printf("%.2lf\n",((double)dp[V])/100.0); } return 0; }
标签:des style blog http java color
原文地址:http://www.cnblogs.com/llei1573/p/3852183.html