From 63e337e06707b891fc2890e0c55c930042bd3904 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 1 May 2024 15:00:15 +0800 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=E5=AE=8C=E5=85=A8?= =?UTF-8?q?=E8=83=8C=E5=8C=85=E9=97=AE=E9=A2=98=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- complete-backup/main.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 complete-backup/main.cc diff --git a/complete-backup/main.cc b/complete-backup/main.cc new file mode 100644 index 0000000..0fd2451 --- /dev/null +++ b/complete-backup/main.cc @@ -0,0 +1,19 @@ +#include +#include +using namespace std; +#define MAXN 10005 +#define M 105 +int dp[MAXN]; +int w[M], v[M]; +int x[M]; +int main() { + int n, W; + cin >> W >> n; + for (int i = 1; i <= n; i++) + cin >> w[i] >> v[i]; + for (int i = 1; i <= n; i++) + for (int j = w[i]; j <= W; j++) + dp[j] = max(dp[j], dp[j - w[i]] + v[i]); + cout << dp[W] << endl; + return 0; +}