#include <iostream>
#include <cstdlib>
#include <stdio.h>
using namespace std;
int T, M;
int t[105], v[105];
int f[1005];
int main()
{
//freopen("medic.in", "r", stdin);
//freopen("medic.out", "w", stdout);
scanf("%d%d", &T, &M);
for(int i = 1; i <= M; ++i)
scanf("%d%d", &t[i], &v[i]);
for(int i = 1; i <= M; ++i)
for(int j = T; j >= t[i]; --j)
f[j] = max(f[j-t[i]]+v[i], f[j]);
cout << f[T] << endl;
return 0;
}
tyvj p1005 采药[背包]
最新推荐文章于 2019-09-27 19:57:55 发布