1 条题解
-
-1njnu19170318 (19170318) LV 8 @ 2019-01-22 20:02:01
#include <iostream>
using namespace std;int main()
{
int n, m, i, x;
int f[10010] = {0};
int w[10010] = {0}, u[10010] = {0};
cin >> n >> m;
for (i = 0; i < m; ++i)
cin >> w[i] >> u[i];
f[0] = 0;
for (i = 0; i < m; ++i)
for (x = w[i]; x <= n; ++x)
if (f[x - w[i]] + u[i] > f[x])
f[x] = f[x - w[i]] + u[i];
cout << f[n] << endl;
return 0;
}
- 1
信息
- 难度
- 3
- 分类
- (无)
- 标签
- (无)
- 递交数
- 82
- 已通过
- 38
- 通过率
- 46%
- 被复制
- 6
- 上传者