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