| 比赛 | 叫图论的DP题 | 评测结果 | AAAAAAAAAA | 
    | 题目名称 | 魅力手镯 | 最终得分 | 100 | 
    | 用户昵称 | Hyoi_iostream | 运行时间 | 0.103 s | 
    | 代码语言 | C++ | 内存使用 | 0.39 MiB | 
    | 提交时间 | 2017-08-29 20:26:09 | 
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int N,M;
int w[3403],d[3403],f[13000];
int main(){
	freopen("charm.in","r",stdin);
	freopen("charm.out","w",stdout);
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++) scanf("%d%d",&w[i],&d[i]);
	for(int i=1;i<=N;i++)
	    for(int j=M;j>=w[i];j--){
	    	int temp=f[j-w[i]]+d[i];
	    	    if(temp>f[j]) f[j]=temp;
		}
	printf("%d",f[M]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}