Here is my code for yesterday LUNCHTIME ARRGAME ,

I couldn’t understand where it failing?

Can anyone help?

PROBLEM LINK:

https://www.codechef.com/problems/ARRGAME

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;

}