| 比赛 | 叫图论的DP题 | 评测结果 | AAAAAAAAAA | 
    | 题目名称 | 开心的金明 | 最终得分 | 100 | 
    | 用户昵称 | Regnig Etalsnart | 运行时间 | 0.000 s | 
    | 代码语言 | C++ | 内存使用 | 0.00 MiB | 
    | 提交时间 | 2017-08-29 20:16:53 | 
显示代码纯文本
#include<iostream>
#include<cstdio>
#define syy myson
using namespace std;
const int maxn=30010;
int n,m,w[30],p,d[30],f[maxn],i,j;
inline void input()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&w[i],&p);
		d[i]=w[i]*p;
	}
}
inline void work()
{
	for(i=1;i<=m;i++)
		for(j=n;j>=w[i];j--)
			if(f[j]<f[j-w[i]]+d[i])
				f[j]=f[j-w[i]]+d[i];
	printf("%d",f[n]);
}
int Main()
{
	freopen("happy.in","r",stdin);freopen("happy.out","w",stdout);
	input();
	work();
	return 0;
}
int main(){;};
int syy=Main();