Tell me why tle occur in mycode
#include
using namespace std;
long long int optimalGame( long long int arr[], long long int i, long long int j){
if(i > j){
return 0;
}
long long int result;
long long int first = arr[i] + min(optimalGame(arr,i+2,j),optimalGame(arr,i+1,j-1));
long long int last = arr[j] + min(optimalGame(arr,i+1,j-1),optimalGame(arr,i,j-2));
result = max(first,last);
return result;
}
int main() {
long long int n;
cin>>n; long long int arr[n];
for( long long int i = 0;i < n;i++){
cin>>arr[i];
}
cout<<optimalGame(arr,0,n-1)<<endl;
return 0;
}