mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
c9791a72c9
4500-4599
28 lines
609 B
C++
28 lines
609 B
C++
#include<iostream>
|
|
#include<string.h>
|
|
const int N=110;
|
|
using namespace std;
|
|
int dp[N*N*10];
|
|
struct Node{
|
|
int a,b;
|
|
}node[N];
|
|
int main(){
|
|
int n;
|
|
while(~scanf("%d",&n)){
|
|
for(int i=0;i<n;i++){
|
|
scanf("%d%d",&node[i].a,&node[i].b);
|
|
}
|
|
int m;
|
|
scanf("%d",&m);
|
|
memset(dp,0,sizeof(dp));
|
|
for(int i=0;i<n;i++){
|
|
for(int j=0;j<=m;j++){
|
|
if(j<node[i].b)continue;
|
|
dp[j]=max(dp[j],dp[j-node[i].b]+node[i].a);
|
|
}
|
|
}
|
|
printf("%d\n",dp[m]);
|
|
}
|
|
return 0;
|
|
}
|