标签:style blog http color io os ar java for
5 20 go 5 8 think 3 7 big 7 4 read 2 6 write 3 5
15
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define pii pair<int,int> 15 #define INF 0x3f3f3f3f 16 using namespace std; 17 int mp[12][12],dp[10010],a[20],n,m; 18 int main() { 19 char s[30]; 20 int u,v,tot; 21 while(~scanf("%d %d",&n,&m)){ 22 memset(mp,0,sizeof(mp)); 23 for(int i = 0; i < n; i++){ 24 scanf("%s %d %d",s,&u,&v); 25 mp[u][v]++; 26 } 27 memset(dp,0,sizeof(dp)); 28 for(u = 0; u < 11; u++){ 29 for(v = 0; v < 11; v++){ 30 if(mp[u][v]){ 31 int t = log2(mp[u][v]); 32 for(int k = 0; k <= t; k++){ 33 if(k == t) a[k] = mp[u][v] - (1<<k) + 1; 34 else a[k] = 1<<k; 35 } 36 for(int k = 0; k <= t; k++){ 37 for(int z = m; z >= a[k]*v; z--){ 38 dp[z] = max(dp[z],dp[z-a[k]*v]+u*a[k]); 39 } 40 } 41 } 42 } 43 } 44 printf("%d\n",dp[m]); 45 } 46 return 0; 47 }
标签:style blog http color io os ar java for
原文地址:http://www.cnblogs.com/crackpotisback/p/4003261.html