I wrote this code for the question with code TEAMFOR in Div 3 in August Cookoff 2021.Though the code gives correct answer, in codechef it says wrong answer.Can someone please help me out in pointing out the error.
The code:
#include <bits/stdc++.h>
using namespace std;
int min(int a,int b)
{
if(a>b)
return b;
else
return a;
}
main()
{
int T;
cin>>T;
int TT=T;
int arr[TT];
while(T>0)
{ int three=0,two=0,one=0,zero=0;
string s,t;
int n;
cin>>n;
cin>>s;
cin>>t;
int ss[n],tt[n];
int i;
for(i=0;i<n;i++)
{
if(s[i]=='0')
{
ss[i]=0;
}
else if(s[i]=='1')
{
ss[i]=1;
}
if(t[i]=='0')
{
tt[i]=0;
}
else if(t[i]=='1')
{
tt[i]=1;
}
}
for(i=0;i<n;i++)
{
if(ss[i]==1&&tt[i]==1)
{
three++;
}
else if(ss[i]==1&&tt[i]==0)
{
two++;
}
else if(ss[i]==0&&tt[i]==1)
{
one++;
}
else zero++;
}
int first=min(one,two);
int resultant=abs(one-two);
int resultant2=resultant+zero;
int second=min(three,resultant2);
arr[T-1]=first+second;
T--;
}
for(int k=TT-1;k>=0;k--)
cout<<arr[k]<<endl;
}