10
25
2015
0

[BZOJ1625] [Usaco2007 Dec] 宝石手镯

水题大法好!

有几天没写blog了呢。因为这几天颓废了。

#include<cstdio>
#include<algorithm>
using namespace std;

int n,m,w[3500],c[3500],f[25000];

int main(){
freopen("1625.in","r",stdin);
freopen("1625.out","w",stdout);
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
    scanf("%d %d",&w[i],&c[i]);
}
for(int i=1;i<=n;i++){
    for(int j=m;j>=w[i];j--){
        f[j]=max(f[j],f[j-w[i]]+c[i]);
    }
}
printf("%d\n",f[m]);
return 0;
}
Category: BZOJ | Tags: bzoj | Read Count: 445

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com