diff --git a/00lanqiao chap/test100-1-2.cpp b/00lanqiao chap/test100-1-2.cpp new file mode 100644 index 0000000..0e74441 --- /dev/null +++ b/00lanqiao chap/test100-1-2.cpp @@ -0,0 +1,28 @@ +// lanqiao 1174 小明的背包1 +#include +using namespace std; +#define int long long +#define endl '\n' +const int N = 1e2+10, M = 1e3 + 10; +int dp[M]; +signed main() +{ + // 请在此输入您的代码 + int n, V; cin >> n >> V; + for(int i = 1; i <= n; i++){ + int w, v; cin >> w >> v; + for(int j = V; j >= w; j--){ + dp[j] = max(dp[j], dp[j-w] + v); + } + } + cout << dp[V] << endl; + return 0; +} +/* test samples -> 37 +5 20 +1 6 +2 5 +3 8 +5 15 +3 3 +*/ \ No newline at end of file