| 记录编号 | 551158 | 评测结果 | AAAAAAAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 71.[NOIP 2006]开心的金明 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.023 s | ||
| 提交时间 | 2020-04-20 10:28:25 | 内存使用 | 13.77 MiB | ||
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,f[30001]={0},v,p;
int main()
{
freopen("happy.in","r",stdin);
freopen("happy.out","w",stdout);
scanf("%d%d",&n,&m);
for(int q=1;q<=m;q++) {
scanf("%d%d",&v,&p);
for(int w=n;w>=v;w--) {
if(f[w-v]+v*p>f[w]) f[w]=f[w-v]+v*p;
}
}
printf("%d\n",f[n]);
return 0;
}