记忆化
by 姬海棠羽立 @ 2017-05-01 12:48:21
```cpp
#include<iostream>
#include<cstdio>
using namespace std;
int dp[1010];
int main(){
int t,n,a,b;
scanf("%d %d",&t,&n);
for(int i=1;i<=n;i++){
scanf("%d %d",&a,&b);
for(int j=t;j>=a;j--){
dp[j]=max(dp[j],dp[j-a]+b);
}
}
printf("%d",dp[t]);
return 0;
}
这样无论是时间还是空间还是代码长度,都应该是极限了
```
by Dark_Kotori @ 2017-05-10 19:52:14
但问题是你的代码错了 @ jfhdnx
你的max函数没有定义
好尴尬呀,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
by 飞奔的蜗牛 @ 2017-06-28 22:10:03
@[奔跑的蜗牛](/space/show?uid=36522) max不是库函数吗?
by Peter_Z @ 2017-07-17 10:54:22