delete pics to save space
This commit is contained in:
17
history_source/信息学奥赛一本通/2.9.2.1.cpp
Normal file
17
history_source/信息学奥赛一本通/2.9.2.1.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<cstdio>
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
int main()
|
||||
{
|
||||
int m,n;
|
||||
scanf("%d%d",&m,&n);
|
||||
int w[n+1],p[n+1];
|
||||
for(int i=1;i<=n;i++)
|
||||
scanf("%d%d",w+i,p+i);
|
||||
int dp[n+1][m+1]={0};
|
||||
for(int i=1;i<=n;i++)
|
||||
for(int j=m;j>0;j--)
|
||||
if(w[i]<=j) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+p[i]);
|
||||
else dp[i][j]=dp[i-1][j];
|
||||
printf("%d\n",dp[n][m]);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user