裸的背包= =,没什么好说的= =
CODE:
#include<cstdio>
#include<iostream>#include<algorithm>#include<cstring>using namespace std;int n,m,f[50010],x;int main(){ scanf("%d%d",&n,&m); for (int i=1;i<=m;i++) { scanf("%d",&x); for (int j=n;j>=x;j--) f[j]=max(f[j],f[j-x]+x); } printf("%d",f[n]); return 0;}