lanqiao 1175 小明的背包2(完全背包)
This commit is contained in:
19
00lanqiao chap/test100-1-4.cpp
Normal file
19
00lanqiao chap/test100-1-4.cpp
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// lanqiao 1175 小明的背包2(完全背包)
|
||||||
|
#include <bits/stdc++.h>
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user