From 8fff611054f3aff07926d65346a4bc3557768d15 Mon Sep 17 00:00:00 2001 From: xingyou wu <3050128610@qq.com> Date: Wed, 9 Apr 2025 14:04:35 +0800 Subject: [PATCH] =?UTF-8?q?lanqiao=201175=20=E5=B0=8F=E6=98=8E=E7=9A=84?= =?UTF-8?q?=E8=83=8C=E5=8C=852(=E5=AE=8C=E5=85=A8=E8=83=8C=E5=8C=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 00lanqiao chap/test100-1-4.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 00lanqiao chap/test100-1-4.cpp 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