| 比赛 | 叫图论的DP题 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 开心的金明 | 最终得分 | 100 |
| 用户昵称 | kZime | 运行时间 | 0.008 s |
| 代码语言 | C++ | 内存使用 | 0.40 MiB |
| 提交时间 | 2017-08-30 19:20:49 | ||
# include <cstdio>
# include <algorithm>
# define MAXN 30023
using namespace std;
int f[MAXN], n, m, t, v;
int main() {
freopen("happy.in", "r", stdin);
freopen("happy.out", "w", stdout);
scanf("%d %d", &n, &m);
for(int i = 1; i <= m; i++) {
scanf("%d %d", &t, &v);
for(int j = n; j >= t; j--) {
f[j] = max(f[j], f[j - t] + v * t);
}
}
printf("%d\n", f[n]);
}