Mixed Pack backpack, if any, it's a 01 backpack.
If you take at most one, it's a normal pack.
If at least one, consider the first and non-first take, note that because the volume can be 0, so first to consider the first take, or a group of the same item will be calculated 2 times
/************************************************************************* > File Name:hdu3535.cpp > Auth Or:alex > Mail: [email protected] > Created time:2015 May 10 Sunday 16:06 19 seconds ******************************** ****************************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;intdp[ the][ the];inttype[ the]; vector <PLL>jobs[ the];intMain () {intN, T, M, C, G; while(~scanf("%d%d", &n, &t)) {memset(DP,-1,sizeof(DP)); for(inti =1; I <= N; ++i) {jobs[i].clear ();scanf("%d%d", &m, &type[i]); for(intj =1; J <= M; ++J) {scanf("%d%d", &c, &g); Jobs[i].push_back (Make_pair (c, G)); } } for(inti =0; I <= t; ++i) {dp[0][i] =0; } for(inti =1; I <= N; ++i) {intSize = Jobs[i].size ();if(Type[i] = =0) { for(intj =0; J < size; ++J) { for(intK = t; K >= Jobs[i][j].first; --K) {if(Dp[i][k-jobs[i][j].first]! =-1{Dp[i][k] = max (Dp[i][k], Dp[i][k-jobs[i][j].first] + jobs[i][j].second); }if(Dp[i-1][k-jobs[i][j].first]! =-1) {Dp[i][k] = max (Dp[i][k], dp[i-1][k-jobs[i][j].first] + jobs[i][j].second); } } } }Else if(Type[i] = =1) { for(intj =0; J <= T; ++J) {Dp[i][j] = dp[i-1][J]; } for(intj =0; J <= T; ++J) { for(intK =0; K < size; ++K) {if(J < Jobs[i][k].first) {Continue; }if(Dp[i-1][j-jobs[i][k].first]! =-1) {Dp[i][j] = max (Dp[i][j], dp[i-1][j-jobs[i][k].first] + jobs[i][k].second); } } } }Else{ for(intj =0; J <= T; ++J) {Dp[i][j] = dp[i-1][J]; } for(intj =0; J < size; ++J) { for(intK = t; K >=0; --K) {if(K < Jobs[i][j].first) { Break; }if(Dp[i][k-jobs[i][j].first]! =-1{Dp[i][k] = max (Dp[i][k], Dp[i][k-jobs[i][j].first] + jobs[i][j].second); } } } } }printf("%d\n", Dp[n][t]); }return 0;}
hdu3535---areyoubusy (mixed group backpack with pit point)