裸的01背包

#include<iostream>
#include<cstdio>
using namespace std;
int c,n,w,v,f[20001];
int main()
{
    scanf("%d%d",&n,&c);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&w,&v);
        for(int j=c;j>=w;j--)
	    f[j]=max(f[j],f[j-w]+v);
    }
    printf("%d",f[c]);
    return 0;
}

相关文章:

  • 2021-12-06
  • 2022-01-08
  • 2021-06-28
  • 2021-11-06
  • 2021-07-29
  • 2021-06-08
  • 2022-01-02
  • 2021-06-07
猜你喜欢
  • 2021-09-17
  • 2022-12-23
  • 2022-01-28
  • 2021-12-23
  • 2021-11-02
  • 2021-10-27
  • 2022-02-18
相关资源
相似解决方案