# 啊啊啊!
## 啊啊!
### 啊!
记忆化搜索也过不了,~~我要抄题解!!!~~
code:
```
#include<bits/stdc++.h>
using namespace std;
int t,m;
int a[10005],b[10005],f[10005];
int dfs(int step,int time,int value)
{
if(step>m)
return 0;
if(time<0)
return 0;
if(f[step]!=-1)
return f[step];
int s1,s2;
s1=dfs(step+1,time-a[step],value+b[step])+value;
s2=dfs(step+1,time,value);
f[step]=max(s1,s2);
return f[step];
}
int main()
{
cin>>t>>m;
memset(f,-1,sizeof(f));
for(int i=1;i<=m;i++)
cin>>a[i]>>b[i];
cout<<dfs(1,t,0);
return 0;
}
```
by poor_OIer @ 2022-07-27 22:53:21
要用dp,dfs时间复杂度太高了
by czk111 @ 2022-08-02 09:50:11
建议不要自己做没学过的题
by zjq123victorW @ 2022-08-17 14:08:39
记忆化搜索能过的哦,我就过了,但是一维dp20ms,记忆化搜索5.95s,高下立判
by Dentist @ 2022-08-20 16:09:39