模板[模板]背包01背包1 2 3 for (int i = 1; i <= n; i++) for (int v = m; v >= w[i]; v--) dp[v] = max(dp[v - w[i]] + c[i], dp[v]); 完全背包1 2 3 for (int i = 1; i <= n; i++) for (int j = w[i]; j <= m; j++) dp[j] = max(dp[j], dp[j - w[i]] + v[i]);