Fall for code 2.0 k halves

link of code
https://www.codechef.com/FFC22019/problems/FFC219G/

what is wrong in my solution

#include<bits/stdc++.h>
using namespace std;
#define iint long long int
iint m=1000000007;
iint f[1000];
iint dp[1000];
iint sum(int x,int i)
{ iint z=i-x+1;
z=z/2;
i=x+z-1;
return(f[i]-f[x-1]);
}
iint func(int x,int n)
{ if(x>=n)
return 0;iint ans=-1000000000000000;
if(dp[x]!=-1)
return dp[x];
for(int i=x+1;i<n;i=i+2)
{

  // cout<<sum(x,i)<<" sum "<<endl;
   //  cout<<" i+1 "<<i+1<<endl;
      ans=max(ans,sum(x,i)+func(i+1,n));
     //   cout<<ans<<endl;    
} 
//cout<<x<<"  "<<ans<<endl;
return dp[x]=ans;

}
int main()
{
iint t;
cin>>t;
while(t–)
{ memset(f,0,sizeof(f));
for(int i=0;i<1000;i++)
dp[i]=-1;
iint n;
cin>>n;
iint a[n];int cc=0;
for(iint i=0;i<n;i++)
{
cin>>a[i];cc=cc+a[i];
if(i==0)
f[0]=a[i];
else
f[i]=a[i]+f[i-1];
} cc=sum(0,n-1);
iint vv=func(0,n); // cout<<vv<<" "<<cc<<endl;
if(vv>=cc)
cout<<vv<<endl;
else
cout<<cc<<endl;

}

}