Why WA in ARRGAME?

Here is my code for yesterday LUNCHTIME ARRGAME ,
I couldn’t understand where it failing?
Can anyone help?

PROBLEM LINK:

SOLUTION LINK:
https://www.codechef.com/viewsolution/37299536

CODE:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll t;
cin >> t;
while (t–)
{
ll n;
cin >> n;
ll arr[n];
for (ll i = 0; i < n; i++)
{
cin >> arr[i];
}
ll ans = 0;
ll finalAns = -1;
for (ll i = 0; i < n; i++)
{
if (arr[i] == 1)
{
if (finalAns < ans)
{
finalAns = ans;
}
ans = 0;
}
else
{
ans++;
}
}
if (finalAns == 1)
{
ll count = 0;
for (ll i = 0; i < n; i++)
{
if (arr[i] == 0)
{
count++;
}
}
if (count == 1)
{
cout << “Yes”
<< “\n”;
}
else
{
cout << “No”
<< “\n”;
}
}
else
{
if (finalAns & 1)
{
cout << “Yes”
<< “\n”;
}
else
{
cout << “No”
<< “\n”;
}
}
}
return 0;
}

The logic you are using is incorrect. The first player would not always choose the longest segment. He would rather choose the longest odd length segment and the second player would choose the longest segment that the first player is not present in. Now if there is no odd length segment, then the answer is “NO”. Else, if there is only one segment and it’s length is odd, then the answer is “YES”. Now, if both of these cases are not true, then the first player chooses the longest odd length segment and the second player chooses the longest segment not taken by the first player(even or odd). Then, we just compare the length of the segment taken by first and then second. The number of moves that the first player will be able to do will be (l/2)+1 and the second player will be L where l and L are the respective lengths of their segments. So the answer is NO if L >= (l/2)+1, else the answer is YES.
https://www.codechef.com/viewsolution/37258043