Showing error in all test cases, cannot find the error.
Not submitting(compiling correctly)
#include
using namespace std;
int n;
int *a;
int dp[1001][1001];
int Solve(int left,int right){
if(right-left<=1)return 0;
int ans=0;
for(int pivot=left+1;pivot<right;pivot++){
ans=max(ans,a[left]*a[pivot]*a[right]+Solve(left,pivot)+Solve(pivot,right));
}
return dp[left][right]=ans;
}
int main(){
//string s;
//cin>>s;
//cout<<Solve(s)<<endl;
int n;
cin>>n;
memset(dp,-1,sizeof(dp));
a=new int[n+2];
a[0]=a[n+1]=1;
for(int i=1;i<=n;i++){
cin>>a[i];
}
return 0;
}
You are not outputting the answer!
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.