Optimal game-1 Correct ans for wrong code

I known my code is incorrect by it is passing the problem
https://ide.codingblocks.com/s/55663

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include<unordered_set>
#include //for srand()
#include
using namespace std;
typedef vector vi;
typedef pair< int,int> ii;
typedef vector<pair<int, int> > vp;
typedef vector<pair<int, ii> > vpp;
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
int64_t s1=0,s2=0,ans1=0,ans2=0;
void recursive(int *ar,int st,int en)
{
//base case
if(st>=en)
{
if(st==en)
{
s1+=ar[st];
}
//cout<<s1<<" β€œ<<s2<<β€œthis is s1 and s2\n”;
if(s1>ans1&&s2>ans2)
{
ans1=s1;
ans2=s2;
}
return;
}
//recursive case
s1+=ar[st];
s2+=ar[st+1];
recursive(ar,st+2,en); //recursive 1
s2-=ar[st+1];
s2+=ar[en];
recursive(ar,st+1,en-1); //recursive 2
s1-=ar[st];
s1+=ar[en];
s2-=ar[en];
s2+=ar[st];
recursive(ar,st+1,en-1); //recursive 3
s2-=ar[st];
s2+=ar[en-1];
recursive(ar,st,en-2); //recursive 4
s1-=ar[en];
s2-=ar[en-1];
}
int main()
{
int n;
cin>>n;
int ar[SIZE];
for(int i=0;i<n;i++)
{
cin>>ar[i];
}
recursive(ar,0,n-1);
cout<<max(::ans1,::ans2)<<”\n";
return 0;
}

paste your code on Coding blocks IDE and share the link here

I have already pasted the link in starting

https://hack.codingblocks.com/contests/c/204/434
If you are taking about this question than you should use DP appraoch to solve it in O(n^2)
Currently you are doing just recusion without memoization.
if you are not taking about above link pls mention your question link .