N, m, and k indicate that there are n pairs of k kinds of shoes, and you have m capacity;
Each pair of shoes has capacity p and value v. If you want to buy all k types of shoes, the maximum value of the shoes can be bought if the capacity is m;
Each pair of shoes can only be bought once (01 backpack). Each type of shoes must have at least one (group backpack: each group can have only one.
Note initialization !!!
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
Using namespace std; # define INF 1e8 # define eps 1e-8 # define LL long # define maxn 127 # define PI acos (-1.0) struct node {int v, p ;} f [11] [10005]; int main () {int n, m, k; int dp [11] [10005]; while (~ Scanf ("% d", & n, & m, & k) {int I, j; int a, B, c; int kao [15]; memset (kao, 0, sizeof (kao); memset (f, 0, sizeof (f); for (I = 0; I
= F [I] [h]. p; j --) {if (dp [I] [j-f [I] [h]. p]! =-1) // The dp [I] [j] = max (dp [I] [j], dp [I] [j-f [I] [h]. p] + f [I] [h]. v); if (dp [I-1] [j-f [I] [h]. p]! =-1) // The dp [I] [j] = max (dp [I] [j], dp [I-1] [j-f [I] [h]. p] + f [I] [h]. v) ;}} if (dp [k] [m] =-1) printf ("Impossible \ n"); else printf ("% d \ n ", dp [k] [m]);} return 0;}/* 5 10 31 4 62 5 73 4 991 55 772 44 66 */