delete pics to save space
This commit is contained in:
16
1.1048.cpp
Normal file
16
1.1048.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include<cstdio>
|
||||
#include<algorithm>
|
||||
using namespace std;
|
||||
int dp[1005];
|
||||
int n,T;
|
||||
int w[105],v[105];
|
||||
int main()
|
||||
{
|
||||
scanf("%d%d",&T,&n);
|
||||
for(int i=1;i<=n;i++) scanf("%d%d",w+i,v+i);
|
||||
for(int i=1;i<=n;i++)
|
||||
for(int j=T;j>=w[i];j--)
|
||||
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
|
||||
printf("%d\n",dp[T]);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user