标签:hdu2191
1 8 2 2 100 4 4 100 2
400
#include <stdio.h> #include <string.h> #define maxn 102 int dp[maxn]; int max(int a, int b) { return a > b ? a : b; } int main() { freopen("stdin.txt", "r", stdin); int T, N, M; int P, H, C; int i, j; scanf("%d", &T); while (T--) { scanf("%d%d", &N, &M); memset(dp, 0, sizeof(dp)); while (M--) { scanf("%d%d%d", &P, &H, &C); for (i = 1; C; C -= i, i <<= 1) { if (i > C) i = C; for (j = N; j >= i * P; --j) dp[j] = max(dp[j], dp[j-i*P] + i * H); } } printf("%d\n", dp[N]); } return 0; }
HDU2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 【多重背包】
标签:hdu2191
原文地址:http://blog.csdn.net/chang_mu/article/details/41526195