7113:Charm Bracelet
题目链接http://noi.openjudge.cn/ch0206/7113/
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct Node {
int w;
int d;
}node;
node a[3500];
int v[13000] = { 0 };
int main() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i].w >> a[i].d;
}
for (int i = 1; i <=n; i++) {
for (int j = m; j >=a[i].w; j--) {
if (a[i].w <= j) {
v[j] = max(v[j], v[j - a[i].w] + a[i].d);
}
}
}
cout << v[m];
return 0;
}