I know my code will give TLE, I just want to know where I am wrong.

Problem: https://codeforces.com/contest/922/problem/E

Basically this is what I did:

f(curmana,manacap,index)=max( itself, i+f(curmana- i * cst[indx]+x,manacap+b * i,indx+1) )

I have checked it for all numbers of bird for each index, hence the forloop.

```
//manacap is the maxmana
int f(int curmana,int manacap,int indx){
if(indx>=n)return 0;
if(curmana<0)return INT_MIN;
if(curmana>manacap)curmana=manacap;
int ans=0;
for(int i=0;i<=bird[indx];i++){
ans=max(ans,i+f(curmana-i*cst[indx]+x,manacap+b*i,indx+1));
}
return ans;
}
//ans is f(w,w,0)
```