希望更丰富的展现?[使用Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
by Quank123Wip @ 2019-01-07 14:25:04
希望更丰富的展现?[使用Markdown](https://www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9%EF%BC%9Amarkdown)
by ZiDing_ByronFinlso @ 2019-01-07 14:50:13
希望更丰富的展现?使用Markdown
by King_of_gamers @ 2019-01-07 14:59:41
```
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
int n, m;
int a[30008][2];
int da[30008][27];
void dp()
{
memset(da, 0, sizeof(da));
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
if (i - a[j][0] >= 0)
da[i][j] = max(da[i - a[j][0]][j - 1] + a[j][0] * a[j][1], da[i][j - 1]);
}
cout << da[n][m];
}
int main()
{
cin >> n >> m;
memset(a, 0, sizeof(a));
for (int i = 1; i <= m; i++)
cin >> a[i][0] >> a[i][1];
dp();
return 0;
}
```
by zhoufangyuanPT @ 2019-01-07 16:30:37