Problem with the code?

#include
#include
using namespace std;
int maximum_value(int input[],int i,int j,int count)
{
if(i==j-1)
return max(input[i],input[j]);
if(input[i]>input[j])
{
if(count%2==0)
return input[i]+maximum_value(input,i+1,j,count+1);
else
return maximum_value(input,i+1,j,count+1);
}
else
{
if(count%2==0)
return input[j]+maximum_value(input,i,j-1,count+1);
else
return maximum_value(input,i,j-1,count+1);
}
}

int main()
{
int n;
cin>>n;
int arr[30];
for(int i=0;i<n;i++)
cin>>arr[i];
cout<<maximum_value(arr,0,n-1,0);
return 0;
}

@namangarg31, Send you code using codingblocks ide due to formatting your code is showing up incorrectly

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.