题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4508
水完全背包~~
#include<iostream>
#include<cstring>
using namespace std;
int A[105],B[105];
int dp[100005];
int main(){
int n,a,b,m;
while(cin>>n){
memset(dp,0,sizeof(dp));
for(int i = 0;i < n;++i)
cin>>A[i]>>B[i];
cin>>m;
for(int i = 0;i < n;++i){
for(int j = B[i];j <= m;++j){
dp[j] = max(dp[j],dp[j - B[i] ] + A[i]);
}
}
cout<<dp[m]<<endl;
}
return 0;
}