裸的背包= =,没什么好说的= =

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;
}

相关文章:

  • 2021-11-06
  • 2021-10-27
  • 2022-03-05
  • 2021-10-04
  • 2022-02-02
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-04
  • 2021-06-22
  • 2022-12-23
  • 2022-02-06
  • 2021-08-17
  • 2022-12-23
  • 2022-01-26
相关资源
相似解决方案