虽不知哪里错了
# 但分享AC代码还是可以的(*≧▽≦)
代码如下
```cpp
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
using namespace std;
const int maxn=1000+5;
int b[maxn];
int main()
{
int T,M,w,v;
scanf("%d%d",&T,&M);
for(int i=1;i<=M;++i)
{
scanf("%d%d",&w,&v);
for(int j=T;j>=w;--j)
b[j]=max(b[j],b[j-w]+v);
}
printf("%d",b[T]);
return 0;
}
```
愿楼主给个赞哈φ(>ω<*)
by Continu @ 2019-11-18 17:26:26
~~为什么一道动规你用的贪心。。。~~
by NuoCarter @ 2019-11-18 17:46:54
~~还两种情况比较最优值~~
你应该是方法错了。。。
by NuoCarter @ 2019-11-18 17:50:10
DP
by xhQYm @ 2019-11-18 18:53:52