Code is giving TLE

#include
#include
using namespace std;
#define ll long long
int compute(int n)
{
map<ll,ll>dp;
if(n==2 || n==3 ||n==4 || n==1)
{
return n;
}
if(dp[n]!=0)
{
return dp[n];
}
int op1,op2,op3;
op1=op2=op3=0;
op1=compute(n/2);
op2=compute(n/3);
op3=compute(n/4);
return dp[n]=max(n,op1+op2+op3);
}
int main()
{
ll n;
cin>>n;
cout<<compute(n);
return 0;
}

@praritv1,
Why are you declaring dp inside the compute function and not global?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.