diff --git a/00lanqiao chap/test100-1-4.cpp b/00lanqiao chap/test100-1-4.cpp new file mode 100644 index 0000000..d0aa9f1 --- /dev/null +++ b/00lanqiao chap/test100-1-4.cpp @@ -0,0 +1,19 @@ +// lanqiao 1175 小明的背包2(完全背包) +#include +using namespace std; +const int N = 1e3 + 10; +int dp[N]; +int main() +{ + // 请在此输入您的代码 + ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); + int n, m; cin >> n >> m; + for(int i = 1; i <= n; i++){ + int w, v; cin >> w >> v; + for(int j = w; j <= m; j++){ + dp[j] = max(dp[j], dp[j-w] + v); + } + } + cout << dp[m] << '\n'; + return 0; +} \ No newline at end of file